处理token失败

main
liutk 2024-05-20 17:00:05 +08:00
parent 023ee3d862
commit f4e380739d
1 changed files with 5 additions and 0 deletions

View File

@ -2,6 +2,7 @@
namespace App\Exceptions;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
use Illuminate\Database\Eloquent\ModelNotFoundException;
@ -34,6 +35,10 @@ class Handler extends ExceptionHandler
if ($request->ajax() || $request->wantsJson()) {
return response()->json(['data'=>null,'code'=>404 , 'message' => '数据未找到,或已被删除' ], 404);
}
}elseif($e instanceof AuthenticationException){
if ($request->ajax() || $request->wantsJson()) {
return response()->json(['data'=>null,'code'=>401 , 'message' => '无效凭证,请先登录' ], 401);
}
}
}
}