Jetstream Inertia Middleware redirects & if issues
Hi
I have a middleware that simply checks if a user is an admin, SuperAdmin or normal user. If either admin it redirects to the an inertia/jetstream admin panel. If not then it redirects to a blade templated front end.
Im having a couple issues where it checks admin fine and redirects. It checks SuperAdmin upon a manual visit but not during login (seems to ignore the SuperAdmin, should redirect after login) and if its not redirecting to the admin backend the front end redirect appears in a modal/iframe rather than redirecting the whole page.
My isAdmin middelware below:
$Admin = false;
if (Auth::user()->role == 'admin'){
$Admin = true;
}
if (Auth::user()->role == 'SuperAdmin'){
$Admin = true;
}
if ($Admin){
return $next($request);
} else {
return Redirect::route('user.dashboard');
}