I have made a middleware for admin routes
public function handle(Request $request, Closure $next)
{
if (!auth()->check() || !auth()->user()->is_admin) {
abort(401);
}
return $next($request);
}
and I have registered it in kernel.php
protected $middlewareAliases = [
'auth' => Authenticate::class,
'admin' => AdminCheck::class,
];
then I added the middleware to my routes
Route::group(['middleware' => ['auth', 'admin', 'verified', 'no-cache']], function () {}
This is for my normal users
Route::group(['middleware' => ['auth', 'verified', 'no-cache']], function () {}
The problem is, when I am logged in as admin, besides seeing my admin area, I can also visit the other routes that normally logedin users see.
How can I prevent that? I mean, if I'm logged in as admin it should be so that I can't visit other routes for normal users.
NotAdminCheckmiddleware and apply to your normal users routes.