Laravel login and logout with two roles -
i have installed adminlte on laravel , it's builtin login functionality works fine. have 2 roles in users table. admin , customer. admin has login through admin panel screen.its works ok. customer has login through front end website login screen. question is:
when login customer through front end website , logins , redirect him/her front page. when open admin panel login screen , redirects admin dashboard login..but must not go admin dashboard,it must remains on admin login page. solution that. how tackle problem?
you use middleware on admin routes check if user admin user, below work if have is_admin
flag on user model:
class isadminmiddleware { /** * handle incoming request. * * @param \illuminate\http\request $request * @param \closure $next * @return mixed */ public function handle($request, closure $next) { if (auth::guest()) { return redirect()->route('login'); } if (!$request->user()->is_admin) { abort(403, 'not authorised'); } return $next($request); } }
Comments
Post a Comment