F
Filament7mo ago
MZX

How to get Filament Auth middleware?

I am trying to use the filament auth page as a middleware on of the routes, how would i go about it?
Route::get('/admin/quiz/{quiz}', showquizauth::class)->name('showquizauth')->middleware('auth.basic');
Route::get('/admin/quiz/{quiz}', showquizauth::class)->name('showquizauth')->middleware('auth.basic');
replace auth basic with filament auth
8 Replies
MZX
MZXOP7mo ago
@Leandro Ferreira i did use a custom page, but auth doesn't work apparently showquizauth is a filament page, but it just skips the auth part
LeandroFerreira
LeandroFerreira7mo ago
do you mean, auth()->user() is null?
MZX
MZXOP7mo ago
what i mean is, showauthquiz is a filament page, that belongs to the admin panel. Admin panel has auth enabled right. so I am going from a non filament page to showauthquiz which is a filament page, so by default it should ask me for auth first right? but it doesn't happen It just lets me access it without having to log in
LeandroFerreira
LeandroFerreira7mo ago
middleware('auth')
MZX
MZXOP7mo ago
Route::get('/admin/quiz/{quiz}', showquizauth::class)->name('showquizauth')->middleware('auth');
Route::get('/admin/quiz/{quiz}', showquizauth::class)->name('showquizauth')->middleware('auth');
like this? I get the route [login] not defined error. i did try auth-basic tho and it worked but its hella basic. i want the filament auth to show up
LeandroFerreira
LeandroFerreira7mo ago
try this
$panel = filament()->getCurrentPanel();

Route::get('/admin/quiz/{quiz}', showquizauth::class)
->name('showquizauth')
->middleware($panel->getAuthMiddleware());
$panel = filament()->getCurrentPanel();

Route::get('/admin/quiz/{quiz}', showquizauth::class)
->name('showquizauth')
->middleware($panel->getAuthMiddleware());
MZX
MZXOP7mo ago
doesn't seem to work, i don't get shown the auth page
Want results from more Discord servers?
Add your server