-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImpersonateManager does not leave the impersonation #77
Comments
For now I've just overwritten the route to log the user right out: Route::get('filament-impersonate/leave', function () {
Auth::logout();
return redirect('/login');
})->name('filament-impersonate.leave'); |
A better workaround for now: Route::middleware(config('filament-impersonate.leave_middleware'))
->get('filament-impersonate/leave', function () {
$manager = app('impersonate');
if ($manager->isImpersonating()) {
$user = $manager->findUserById($manager->getImpersonatorId());
Auth::quietLogout();
Auth::quietLogin($user);
$manager->clear();
}
return redirect('/');
})
->name('filament-impersonate.leave'); |
I have this issue as well using Laravel 11. What "fixed" it for me was removing my global scopes (not what I wanted to do) so I just added a check for the leave route: protected static function booted(): void
{
// Workaround for filament impersonate leave bug.
if (request()?->route()?->getName() !== 'filament-impersonate.leave') {
static::addGlobalScope(new ViewableByCurrentUser());
}
} |
Worked for me as well. Thanks! |
Ah, global scopes would make sense. Interesting. Any thoughts on how this package could provide an option or hook for this? I'm wondering if the leave route should use |
I'm on Laravel 11
When I click
Leave
in the banner, nothing happens.I've narrowed it down to the
ImpersonateManager
leave
method not working.Which as to do with the package this package uses.
The text was updated successfully, but these errors were encountered: