Redirection On Login

Feb 16, 2017 redirection laravel php login
If we’d like to provide an admin area and a standard user area, this can be done in the file Auth/LoginController.php in the function authenticated() which you must include yourself, to override the method

protected function authenticated(Request $request, User $user)
// redirect to the regular 'after login' route
//check user role
if( $user->hasRole('Admin') || $user->hasRole('Master') ) {
return redirect()->intended('/masterhome');
else {
return redirect()->intended('/home');


The main block of code we should concentrate on is the first if statement. In this block we grab the user data that is attempting to sign in and check the role of the account. Then we proceed to redirect the user to their destination URL.

Note: This is for Laravel 5.3

If you found the following info helpful, I'm happy to accept any donations of the following cryptocurrencies.

  • Bitcoin - 17DTiPExzP9StqveW428acEyB4mVMfKbiK
  • Ethereum - 0x87B8307FD20dc90cc05c94905Ec593134D32B6FF
  • Litecoin - LZMiz5U5sVq9doMLYE3gfLJrxCQDKuyCmU
  • Neo - AXv71WB38ajc1KUUEnxQKhynLLPc4BapVb