2
嘗試使用laravel默認控制器(AUTH /口令)來實現我的網站上簡單的用戶註冊/登錄功能,但只要我登錄,類RedirectIfAuthenticated手柄功能可以防止所有訪問驗證網址的,因此我不能註銷了。是否有一個錯誤,我需要寫在手柄功能異常或有我錯過了什麼? 這裏是一流的樣子默認:Laravel認證的用戶註銷錯誤
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
//dd($next($request));
if (Auth::guard($guard)->check()) {
return redirect('/articles');
}
return $next($request);
}
}
該解決方案適用於Laravel 5+。如果您使用Laravel,請考慮使用過濾器而不是中間件。我認爲解決方案應該是一樣的。 – whoan
感謝您的解釋! :) – MattJ
這完全由注重我的''except''關鍵的幫助。我的控制器行動是'getLogout()',所以中間件是防止註銷。將中間件更改爲'getLogout'併成功! – JoshP