Adding routes to Filament auth middleware
I have a Filament user panel where a website user can do normal CRUD operations after he logs in.
I want to integrate Stripe billing in the user panel. I can show the (typical) Stripe logout form. I would like this form to be only available when a user is logged in in the user panel. A user that is not loggin in should be redirected to the login page. The associated route is under
/user/billing
.
I was adding it to my usual Laravel routes file as follows:
Route::middleware('auth')->group(function () {
Route::get('/user/billing', Billing::class)->name('billing');
});
but then I get the Route [login] not defined
because it checks the app\Http\Middleware\Authenticate.php
file which does refer to login (but not the login from Filament).
Any idea how to fix this?3 Replies
You can try adding this to your routes
(from here https://github.com/filamentphp/filament/discussions/5226)
Solution
Thanks. Based on your response I have tried two things. Both work
Route::redirect('/user/billing', 'login')->name('billing');
and
Route::get('/user/billing', function () {
return redirect(route('filament.user.auth.login'));
})->name('billing');