Skip to content

Commit

Permalink
Clear session on impersonation exception
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed Feb 28, 2024
1 parent d8ab69f commit 7b793ef
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Services/ImpersonateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ public function take($from, $to, $guardName = null)
$this->saveAuthCookieInSession();

try {
if (
!method_exists($this->app['auth']->guard($currentGuard), 'quietLogout')
|| !method_exists($this->app['auth']->guard($guardName), 'quietLogin')
) {
return false;
}

$currentGuard = $this->getCurrentAuthGuardName();
session()->put($this->getSessionKey(), $from->getAuthIdentifier());
session()->put($this->getSessionGuard(), $currentGuard);
Expand All @@ -122,6 +129,7 @@ public function take($from, $to, $guardName = null)

} catch (\Exception $e) {
unset($e);
$this->clear();
return false;
}

Expand Down

0 comments on commit 7b793ef

Please sign in to comment.