Im trying to setup the ability to redirect the user to the original intended url.
If a user visits a url and is required to login, it should redirect them to the original url they visited. Ive been doing some reading on Stackoverflow and have come to these solutions, however I cant get it to function as intended (no intended pun :) )
Any ideas on what I am doing wrong?
I am on Laravel 5.4.36
My LoginController.php
if (Auth::attempt($credentials, $remember_me, $user->status == 'Confirmed')) {
if ($control_panel->auth_throttle == "on") {
$this->clearLoginAttempts($request);
}
// Added if statement if user is super admin we'll direct to their
// dashboard
if ($user->superadmin == true) {
return redirect()->intended("/admin");
}
// if user is not superadmin we'll direct them to their
// dashboard
else {
return redirect()->intended("v1");
}
}
My RedirectIfAuthenticated.php
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect()->intended();
//return redirect('/admin');
}
return $next($request);
}
From my understanding of reading your question, you want to redirect a user BACK to the previous route after authentication?
Laravel has a back helper.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.