F
Filament7mo ago
Wim

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?
Solution:
Thanks. Based on your response I have tried two things. Both work
Jump to solution
3 Replies
ChesterS
ChesterS7mo ago
You can try adding this to your routes
Route::redirect('/laravel/login', '/login')->name('login')
Route::redirect('/laravel/login', '/login')->name('login')
(from here https://github.com/filamentphp/filament/discussions/5226)
Solution
Wim
Wim7mo ago
Thanks. Based on your response I have tried two things. Both work
Wim
Wim7mo ago
Route::redirect('/user/billing', 'login')->name('billing'); and Route::get('/user/billing', function () { return redirect(route('filament.user.auth.login')); })->name('billing');