csabit1000
csabit1000
FFilament
Created by csabit1000 on 5/30/2024 in #❓┊help
Downloading exported resources problem (problem with the auth guards)
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
use Filament\Actions\Exports\Http\Controllers\DownloadExport;

Route::get('/filament/exports/{export}/download', DownloadExport::class)
->name('filament.exports.download')
->middleware(['web', 'auth:admin']);
use Filament\Actions\Exports\Http\Controllers\DownloadExport;

Route::get('/filament/exports/{export}/download', DownloadExport::class)
->name('filament.exports.download')
->middleware(['web', 'auth:admin']);
7 replies
FFilament
Created by csabit1000 on 5/30/2024 in #❓┊help
Downloading exported resources problem (problem with the auth guards)
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.
7 replies
FFilament
Created by csabit1000 on 5/30/2024 in #❓┊help
Downloading exported resources problem (problem with the auth guards)
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:
public function panel(Panel $panel): Panel
{
// get the original panel to extend it
$customPanel = parent::panel($panel);

// the panel from the package that is customizable
return $customPanel
->databaseNotifications();
}
public function panel(Panel $panel): Panel
{
// get the original panel to extend it
$customPanel = parent::panel($panel);

// the panel from the package that is customizable
return $customPanel
->databaseNotifications();
}
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
/**
* Register any application services.
*/
public function register(): void
{
$this->app->bind(Authenticatable::class, Admin::class);
}
/**
* Register any application services.
*/
public function register(): void
{
$this->app->bind(Authenticatable::class, Admin::class);
}
Exports migration:
$table->foreignId('user_id')->constrained('admins')->cascadeOnDelete();
$table->foreignId('user_id')->constrained('admins')->cascadeOnDelete();
7 replies