简体   繁体   English

在 laravel 6 中,当我使用 logoutOtherDevices() 时,其他设备注销但重定向到登录页面。 如何将其更改为主页?

[英]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?

I am using Custom authentication and middleware but when using logoutOtherDevices function its working but redirecting them to /login.我正在使用自定义身份验证和中间件,但是当使用 logoutOtherDevices 功能时,它可以正常工作,但会将它们重定向到 /login。 And i want to redirect them to home page ie /home我想将它们重定向到主页,即 /home

You need to override the unauthenticated method that are extendble class of app\/Exceptions\/Handler.php, this file is the default file of laravel that handle when the session expired.你需要重写app\/Exceptions\/Handler.php的extendble类的未认证方法,这个文件是laravel的默认文件,在会话过期时处理。 To solve that just write this code in your app\/Exceptions\/Handler.php要解决这个问题,只需在您的 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.

相关问题 当用户单击注销并重定向到主页时,我想加载一个gif图像。 我正在尝试使用php - 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 如何在Laravel应用程序中将登录行为从/ login URL移到我的主页? - How can I move the login behaviour from the /login URL to my home page in a Laravel application? Laravel成功登录后如何更改登录页面? - How can I change the landing page after a success Laravel login? 我是否需要在每个页面中定义会话。 我不希望被重定向到每个页面登录 - Do I need to define session in every page. I do n't want to be redirected for each page to login 当我尝试访问主页时,Laravel 不会重定向到登录页面 - Laravel does not redirect to login page when I try to access to home page Laravel 5:登录后,用户被重定向到/ home。 如何改变呢? - Laravel 5: After login the user is was redirected to /home. How to change that? 如何使用Laravel 5.3注销并重定向到登录页面? - How to logout and redirect to login page using Laravel 5.3? 如何使用 Laravel 5.4 注销并重定向到登录页面? - How to logout and redirect to login page using Laravel 5.4? 如何使用cURL登录并获取重定向页面 - how to login and get the redirected page using cURL 如何为其他服务器上的重定向页面或新打开的页面设置超时时间? - How can I set timeout for redirected or for new opened page on other server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM