diff --git a/src/Services/ImpersonateManager.php b/src/Services/ImpersonateManager.php index 5bdd05a..7b8b57c 100644 --- a/src/Services/ImpersonateManager.php +++ b/src/Services/ImpersonateManager.php @@ -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); @@ -122,6 +129,7 @@ public function take($from, $to, $guardName = null) } catch (\Exception $e) { unset($e); + $this->clear(); return false; }