mberneis
mberneis
FFilament
Created by mberneis on 5/3/2024 in #❓┊help
How do I programatically log into filament?
My Filament has resource pages for admins and non-admins. - I have a user resource and a table-action to impersonate users. I am using this code:
Tables\Actions\Action::make('Impersonate')
->icon('heroicon-o-user')
->color('info')
->action(function (User $user) {
Filament::auth()->login($user);
Filament::auth()->setUser($user);
return redirect()->route('filament.app.pages.home');
})
Tables\Actions\Action::make('Impersonate')
->icon('heroicon-o-user')
->color('info')
->action(function (User $user) {
Filament::auth()->login($user);
Filament::auth()->setUser($user);
return redirect()->route('filament.app.pages.home');
})
The Home page is a guest page and not authenticated - I can see in that page the user avatar and my badges in the navigation bar calculated from the current user. - But once I click on a regular Filament page I get the login panel. - What else do I need to do to make Filament switch to the new user?
3 replies