1
我正在使用Laravel的本地驗證模塊進行登錄並使用委託給用戶角色。Laravel:登錄後的空白頁面,然後檢查角色
當用戶登錄時,laravel的本機認證模塊僅檢查用戶名/電子郵件和密碼。然後登錄用戶。我已經檢查用戶是否使用特定的user_type(user_type也發佈了)並且用戶具有該角色登錄,然後用戶被髮送到該角色的儀表板,否則用戶通過Auth :: logout登出並重定向到錯誤的user_type錯誤的登錄頁面。
所有代碼都可以工作,除非user_type錯誤,則顯示空白登錄頁面。我嘗試了很多重定向的組合,但沒有運氣。
我的註銷代碼和重定向是
protected function logoutRedirect(Request $request)
{
Auth::logout();
return redirect($this->loginPath())
->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([
$this->loginRole() => $this->getWrongRoleMessage(),
]);
/*
return view('auth.login')
->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors($this->getWrongRoleMessage());
*/
/*
return redirect('/auth/login')->withErrors([$this->loginRole() => $this->getWrongRoleMessage()]);
*/
}
我已經把所有的重定向方法我可以嘗試在評論形式上面的代碼。如果你能找到這些錯誤,或者你可以提出更好的解決方案,請告訴我。我是laravel的新人,所以如果你能幫我解決這個初學者問題,我將不勝感激。
PS:由我使用Laravel 5.1和本地主機(XAMPP +微軟Windows 7)
試試這個'返回重定向到::( '登錄') - > withInput(輸入::除了( '密碼')) - > withErrors([$這個 - > loginRole()=> $這個 - > getWrongRoleMessage(),]);'。請記住使用重定向門面。 – karmendra
@karmendra是的我試過你的代碼,但它不起作用。 –