当会话过期时,我的用户被重定向到/login
,但是应该将它们重定向到/backoffice/login
,是否有人知道我可以在哪个文件中更改重定向部分?
答案 0 :(得分:1)
您的异常处理程序将获取所有未经身份验证的请求,并以您需要的方式处理它们。
看起来像这样:
应用程序/异常/ Handler.php
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
return redirect()->guest('login');
}
您可以通过将return redirect()->guest('login');
更改为return redirect()->guest('backoffice/login');