dota220141003
2018-03-26 09:19 阅读 38

在管理员和客户登录重定向的laravel 5.6.12中找不到函数unauthenticated()函数? [关闭]

How can admin and user be redirected in laravel 5.6.12? I cannot find unauthenticated function in app/Exceptions/Handler.php file..

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • duan7664 duan7664 2018-03-26 13:05

    The unauthenticated method exists in the parent handler, Illuminate\Foundation\Exceptions\Handler. Just override it, like so;

    protected function unauthenticated($request, AuthenticationException $exception) {
        if ($request->expectsJson()) {
            return response()->json(['message' => $exception->getMessage()], 401);
        }
    
        $guard = $exception->guards()[0];
    
        return redirect(route($guard . ':auth.create'));
    }
    
    点赞 评论 复制链接分享

相关推荐