我正在尝试设置将用户重定向到原始预期URL的功能。
如果用户访问一个URL并需要登录,则应将其重定向到他们访问的原始URL。我一直在阅读一些关于Stackoverflow的文章,并且已经找到了这些解决方案,但是我无法使其按预期的功能运行(没有预期的双关语:))
关于我在做什么错的任何想法吗?
我正在使用Laravel 5.4.36
我的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");
}
}
我的RedirectIfAuthenticated.php
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect()->intended();
//return redirect('/admin');
}
return $next($request);
}
答案 0 :(得分:-1)
根据我对阅读问题的理解,您想在身份验证后将用户BACK重定向到上一条路由吗?
Laravel有一个后帮手。