mirror of
https://github.com/koel/koel
synced 2024-11-24 21:23:06 +00:00
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:
parent
2bd4b79a04
commit
9f11a7111e
1 changed files with 2 additions and 2 deletions
|
@ -19,7 +19,7 @@ class GetUserFromToken extends BaseMiddleware
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
if (!$token = $this->auth->setRequest($request)->getToken()) {
|
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 {
|
try {
|
||||||
|
@ -31,7 +31,7 @@ class GetUserFromToken extends BaseMiddleware
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user) {
|
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);
|
$this->events->fire('tymon.jwt.valid', $user);
|
||||||
|
|
Loading…
Reference in a new issue