I have setup 2 auth. One is original user Auth and another is Admin auth. I didn't touch the Login controller so the redirect()->intended('dashboard') is left untouch. It seem to work on fresh install though but my project is way to far to redo.
Here's the code that I customize if user not authenticated will redirect to the right login page:
App\Exceptions\Handler.php
....
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
if ($exception instanceof AuthenticationException) {
$guard = array_get($exception->guards(), 0);
switch ($guard) {
case "admin":
return redirect((route('admin.login')));
break;
default:
return redirect((route('login')));
break;
}
}
return parent::render($request, $exception);
}
.....
LoginController.php (Left un-touch)
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/dashboard';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
Seem like the session fail and redirect to default route which is '/dashboard'. I don't know how to debug that, though.