[英]Laravel 5.4 Redirect back to intended 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);
}
根據我對閱讀問題的理解,您想在身份驗證后將用戶BACK重定向到上一條路由嗎?
Laravel有一個后幫手。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.