Downloading exported resources problem (problem with the auth guards)
I have a filament resource and I want to export then download them as a csv file. I set up everything as the filament documentation said so I can export the resources with a bulk action, then I get the notification where I can click the download csv button.
After I did these I got the error
Route [login] not defined
. So I added this code to the web.php:
With this modification it doesn't gives the error but the system opens a new window and redirects me to my filament dashboard instead of the csv gets downloaded.
Anyone have something in mind what can I do with this?Solution:Jump to solution
I managed to discover the problem and solved it!
The problem is that my filament app uses admin auth guard but the page where the download happens uses the user auth guard...
That was why the system wanted to log me in.
...
3 Replies
Please find your Filament Service Provider, and check if there is ->login() else add it.
Yes I have
->login()
in on my panel in the panel provider.
Actualy I have a package which creates a panel in the PackagePanelProvider and there are set the main panel options that are important for me (resources, navigationGroups etc.)
I use that package in my project and the ProjectPanelProvider extends the PackagePanelProvider. So theoretically if I override the panel function of the PackagePanelProvider and call the parent panel function I could use the predefined panel:
Note: The panel of the PackagePanelProvider uses the ->login()
option. (Also I have tried to apply the ->login()
in the ProjectPanelProvider too, but no luck)
One more important thing. My export user isn't the default user model. I changed it to my admin model.
AppServiceProvider.php
Exports migration:
One more thing that I discovered yesterday that on the download .csv click I don't have any guards. I have called dd(auth())
from the Authenticate middleware and the guards
array is completely empty.Solution
I managed to discover the problem and solved it!
The problem is that my filament app uses admin auth guard but the page where the download happens uses the user auth guard...
That was why the system wanted to log me in.
The work around (actually a hack) that I used is to redefine the download route in the
web.php
and use the appropriate guard.
web.php