F
Filament4mo ago
Diego

Filament's CanExportRecords trait doesn't seem to respect the configured auth guard

I have a project where there are two auth guards: "admin" and "web" (user). Both the admin and web (user) can be simultaneously logged in on the same browser. In my panel provider, the admin guard is defined with $panel->authGuard('admin'). This all works as expected. However, I am now trying to make use of Filament's built-in export actions. When I try to export something, the exports table user_type (morph) is set to user, and same for the notifications table notifiable_type. This means that it does not use the guard that I defined in the panel provider. From what I can see, this is happening because the filament/actions/src/Concerns/CanExportRecords.php file gets the user by doing $user = auth()->user(), and this doesn't respect the guard that is defined in the Filament panel provider. If I manually overwrite this line to do $user = Filament::auth()->user(), the exports table will save the correct user_type. However, the notifications table notifiable_type will still be saved as user, and not admin.. Am I missing a configuration step somewhere? I have already added Export::polymorphicUserRelationship() to my service provider's boot method.
0 Replies
No replies yetBe the first to reply to this messageJoin