In laravel have added socialite login for google,but i wanted them to be authenticated first before going to /studentTable route. And if they are not authenticated then they go back to login.
Im new to laravel and is this possible?, i tried middleware('auth'); and middleware('guest') but it wont work in socialite.
Route::get('/studentTable',[StudentController::class, 'viewAllStudent'])->middleware('auth');
Route::get('/login',[UserController::class, 'loginFunction'])->name('login')->middleware('guest');
When using socialite authentication, the auth middleware alone may not be enough, like in your case. Instead, you can create a custom middleware that checks for both socialite authentication and regular authentication.
Middleware:
Register the middleware in Kernel.php
Route: