📜  传递给 App\Exceptions\Handler::unauthenticated() 的参数 2 必须是 App\Exceptions\AuthenticationException 的实例,给出的 Illuminate\Auth\AuthenticationException 实例 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:38.190000             🧑  作者: Mango

代码示例2
protected function unauthenticated($request, AuthenticationException $exception)
{
    if ($request->expectsJson()) {
        return response()->json(['error' => 'Unauthenticated.'], 401);
    }

    return redirect()->guest('/');
}