jaurenigel
3 months ago

Redirect After Login With User Roles

Posted 3 months ago by jaurenigel

Hello guys.

I am trying to redirect a user after login. I want a user employee to be redirected to /home and user admin to /admin. Only one user is redirected and the other is showing 401 Unauthorized and the url is still /login.

public function redirectTo(){

    if (Auth::user()->authorizeRoles('employee') == true) {
       return '/home';
    }else if (Auth::user()->authorizeRoles('admin') == true) {
       return view('admin');
    }else {
      return 'login';
    }

Please sign in or create an account to participate in this conversation.