#Authentication loop issue: Redirecting from login to dashboard to login page
7 messages · Page 1 of 1 (latest)
I am using the default laravel 11 breeze routes for login. These are the middlewares I have
if (!Auth::user()->role ==='student') {
return redirect(route('404-error'))->withErrors('Access denied');
}
return $next($request);
They're just basically checking if the roles are what they're supposed to be for access protectiob
I'm trying to create an authentication from my students table instead of the default user table. I only changed the provider for the web guard as Students::Class. Other than that there's just my logic in the AuthenticatedSessionController
This is the response that is being sent in the network in the inspect element
Are there any errors in the log? Also are you sure that your middleware runs after auth middleware? If not, then Auth::user() is null
Route::get('/student/dashboard', [StudentController::class, 'index'])->middleware(['auth', 'roleManager:student'])->name('student.dashboard');
I am. When I die dump the Auth::user in my store function in AuthenticatedSessionController, it says the user is authenticated.
Please show the full roleManager:student middleware