Fix HTTP error code when bad authentication to 401

…instead of 400/404, so client can deal with it correctly (#537)
This commit is contained in:
X-Ryl669 2017-02-09 13:06:39 +01:00 committed by Phan An
parent 2bd4b79a04
commit 9f11a7111e

View file

@ -19,7 +19,7 @@ class GetUserFromToken extends BaseMiddleware
public function handle($request, Closure $next)
{
if (!$token = $this->auth->setRequest($request)->getToken()) {
return $this->respond('tymon.jwt.absent', 'token_not_provided', 400);
return $this->respond('tymon.jwt.absent', 'token_not_provided', 401);
}
try {
@ -31,7 +31,7 @@ class GetUserFromToken extends BaseMiddleware
}
if (!$user) {
return $this->respond('tymon.jwt.user_not_found', 'user_not_found', 404);
return $this->respond('tymon.jwt.user_not_found', 'user_not_found', 401);
}
$this->events->fire('tymon.jwt.valid', $user);