Cannot access authenticated user from within filament admin panel provider
When I use the following code:
$user = auth()->user();
from within the panel method of the AdminPanelProvider, I get null, even when the user is logged in.
Here is my user model declaration:
class User extends Authenticatable implements FilamentUser
How do I access the currently logged in user from there?
Give it a shot using Auth::user() or $request->user() or just clear your Cache. :)
Turns out it is not possible.
You can only access the logged in user via a callable.
@ksorbo Can you try this?
$user = \Filament\Facades\Filament::auth()->user();
According to my knowledge, it ensures you're pulling the user from Filament's admin panel authentication context, not the default Laravel guard.
Why? What are you trying to achieve in the service provider that requires the user?
try getting it inside a closure function.
Please or to participate in this conversation.