Oh, and by the way. The user is being redirected to the login page using Entrust's Middelware.
I just did a test with these routes:
Route::get('/works', ['middleware' => 'auth']);
Route::get('/does-not-work', ['middleware' => ['role:admin']]);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all,
as far as I can tell, the default code in Laravel that I'm using should redirect my users to the page they tried to visit before being prompted with the login screen. At least, that's what I make out of this code:
/**
* Send the response after the user was authenticated.
*
* @param \Illuminate\Http\Request $request
* @param bool $throttles
* @return \Illuminate\Http\Response
*/
protected function handleUserWasAuthenticated(Request $request, $throttles)
{
if ($throttles) {
$this->clearLoginAttempts($request);
}
if (method_exists($this, 'authenticated')) {
return $this->authenticated($request, Auth::user());
}
return redirect()->intended($this->redirectPath());
}
intended() defaults to the redirectPath set in my AuthController which is /dashboard. However, all logins are being redirected to /dashboard and seem to bypass any intended link. I tried to add this to my AuthController to see if the intended URL is at least available:
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
$this->loginPath = route('auth.login');
$this->redirectPath = Session::get('url.intended', route('member.dashboard'));
if(Request::route()->getName() == "auth.login" ) {
dd(Session::get('url.intended', route('member.dashboard')));
}
}
(P.S. I put the loginPath and redirectPath vars inside the constructor to be able to use the route helper function.)
But the above always returns "/dashboard" no matter what I try.
Am I mistaking what intented() should do?
have you tried?
['middleware' => ['auth', 'role:admin']]
Please or to participate in this conversation.