Filament::auth()->login();

Situation: - I am logged in to panel as User1 - I go to
myapp.test/somepage
myapp.test/somepage
page which is outside of panel. - In that page I call
Filament::auth()->login($anotherUserModel);
Filament::auth()->login($anotherUserModel);
($anotherUserModel is another user) - Then I redirect back to my panel - And I get
Route [login] not defined.
Route [login] not defined.
error. And I'm not logged in as $anotherUserModel I don't get this error if I call
Filament::auth()->login($anotherUserModel)
Filament::auth()->login($anotherUserModel)
when I'm currently not logged in as some other user. I tried to do
Filament::auth()->logout()
Filament::auth()->logout()
before
Filament::auth()->login($anotherUserModel)
Filament::auth()->login($anotherUserModel)
but that does not help. Am I missing something?
Solution:
Thanks for your effort. Actually I needed to call these, if user is currently logged in: Filament::auth()->logout() session()->invalidate() session()->regenerateToken()...
Jump to solution
4 Replies
Dan Harrin
Dan Harrin8mo ago
its a laravel bug, create a route named "login" and redirect to your actual login page
dreftas
dreftasOP8mo ago
@Dan Harrin for Route [login] not defined yeah, defining my route that redirects to Filament login page solved problem. But most important one is, that Filament::auth()->login($userModel) does not login me as specified $userModel, I'm not logged in as anyone after that function. What I expect that if I use Filament::auth()->login($userModel) I should be logged in as that user.
Dan Harrin
Dan Harrin8mo ago
Open an issue with a reproduction repository
Solution
dreftas
dreftas8mo ago
Thanks for your effort. Actually I needed to call these, if user is currently logged in: Filament::auth()->logout() session()->invalidate() session()->regenerateToken() And now everything works fine, Filament::auth()->login($model) does its job. Thanks again.
Want results from more Discord servers?
Add your server