Skip to content

Clear session on impersonation exception#193

Open
erikn69 wants to merge 2 commits into
404labfr:masterfrom
erikn69:patch-1
Open

Clear session on impersonation exception#193
erikn69 wants to merge 2 commits into
404labfr:masterfrom
erikn69:patch-1

Conversation

@erikn69

@erikn69 erikn69 commented Feb 28, 2024

Copy link
Copy Markdown
Contributor

When quietLogout doesn't exists, take returns false, but session keeps impersonated_by, this causes the app to behave as if it is being impersonated to another user when in reality that is not the case
When quietLogin doesn't exists, take returns false but current user already be logout, and no user is logged in

session()->put($this->getSessionKey(), $from->getAuthIdentifier());
session()->put($this->getSessionGuard(), $currentGuard);
session()->put($this->getSessionGuardUsing(), $guardName);
$this->app['auth']->guard($currentGuard)->quietLogout();
$this->app['auth']->guard($guardName)->quietLogin($to);
} catch (\Exception $e) {
unset($e);
return false;

public function isImpersonating(): bool
{
return session()->has($this->getSessionKey());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants