![](/img/trans.png)
[英]I want to load a gif image when user clicks on logout and then redirects to home page. i am trying to do using php
[英]In laravel 6, when I'm using logoutOtherDevices(), other devices got logout but redirected to login page. How can I change it to home page?
我正在使用自定義身份驗證和中間件,但是當使用 logoutOtherDevices 功能時,它可以正常工作,但會將它們重定向到 /login。 我想將它們重定向到主頁,即 /home
你需要重寫app\/Exceptions\/Handler.php的extendble類的未認證方法,這個文件是laravel的默認文件,在會話過期時處理。 要解決這個問題,只需在您的 app\/Exceptions\/Handler.php 中編寫此代碼
protected function unauthenticated($request, AuthenticationException $exception)
{
return $request->expectsJson()
? response()->json(['message' => $exception->getMessage()], 401)
: redirect()->guest($exception->redirectTo() ?? route('YOUR ROUTE HERE'));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.