我使用自定义身份验证和中间件,但是当使用logoutOtherDevices函数时,它可以工作,但将它们重定向到/login。我想把它们重定向到主页,即/home
发布于 2022-01-25 18:55:24
您需要覆盖未经验证的方法,该方法是app/Exception/Handler.php的可扩展类,此文件是laravel的默认文件,在会话过期时处理。要解决这个问题,只需在app/Exception/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'));
}https://stackoverflow.com/questions/64588885
复制相似问题