Skip to content

Commit

Permalink
[BF] - admin 'log on as this user' updates last login date - fixes #652
Browse files Browse the repository at this point in the history
  • Loading branch information
yannrobin committed Jun 11, 2020
1 parent 90c48a3 commit 526da5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/Auth/SwitchUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public function switch( int $id ){
AlertContainer::push( "This user doesnt have customer associated.", Alert::DANGER );
return redirect()->to( "/" );
}

Auth::login( $nuser );


session()->put( "switched_user_from", $user->getId() );
session()->put( "redirect_after_switch_back", request()->headers->get('referer', "" ) );

Auth::login( $nuser );

AlertContainer::push( "You are now logged in as {$nuser->getUsername()} ". "(" . Auth::getUser()->getName() . ")", Alert::SUCCESS );

return redirect()->to( "/" );
Expand Down
2 changes: 1 addition & 1 deletion app/Listeners/Auth/LoginSuccessful.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LoginSuccessful {
*/
public function handle( LoginEvent $e )
{
if( $e->user->getCurrentCustomerToUser() ) {
if( !session()->exists( "switched_user_from" ) && $e->user->getCurrentCustomerToUser() ) {
if( Auth::viaRemember() ) {
$e->user->getCurrentCustomerToUser()->setLastLoginVia( 'RememberMe' );
} else {
Expand Down

0 comments on commit 526da5b

Please sign in to comment.