Filament::auth()->login($user), multiple guards
How does
Filament::auth()->login($user)
deal with issue where there are multiple panels and guards?
Looking from a testing perspective, can I specify the guard to use?3 Replies
It would log them in directly bypassing the guards looking a the code.
Cheers, it seems to work for whichever user model I am trying for, so I'm not going to argue with it. I hate tests enough already !
Maybe this article cans help you : https://filamentmastery.com/articles/implementing-filament-auth-guard
For testing i init panel in TestCase with :
Filament::setCurrentPanel(
Filament::getPanel(FilamentPanelEnum::BACKEND->value)
);
And acting as
with :
$this->actingAs($member, Filament::getAuthGuard());
When you manage policy you can check permission like this if you use spatie permissions package:
public function viewAny(User $user): bool
{
return $user->hasPermissionTo('view-any broker', filament()->getAuthGuard());
}
Filament Mastery
Implementing Filament Auth Guard - Filament Mastery
Learn how to configure multi auth guards in Filament by creating a Member panel with a custom guard, provider, and password reset flow, linked to a Member Model