Skip to content

Commit 9b74da3

Browse files
committed
fix: 🐛 rename class
1 parent 8494727 commit 9b74da3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/JwtAuth.php renamed to src/JWTAuth.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Anddye\JWTAuth;
44

5+
use Anddye\JWTAuth\Exceptions\InvalidCredentialsException;
6+
use Anddye\JWTAuth\Exceptions\InvalidTokenException;
57
use Anddye\JWTAuth\Interfaces\AuthProviderInterface;
68
use Anddye\JWTAuth\Interfaces\ClaimsInterface;
79
use Anddye\JWTAuth\Interfaces\JWTProviderInterface;
@@ -25,7 +27,7 @@ public function __construct(AuthProviderInterface $authProvider, JWTProviderInte
2527
public function attempt(string $username, string $password): ?string
2628
{
2729
if (!$user = $this->authProvider->byCredentials($username, $password)) {
28-
throw new Exceptions\InvalidCredentialsException();
30+
throw new InvalidCredentialsException();
2931
}
3032

3133
return $this->fromSubject($user);
@@ -35,7 +37,11 @@ public function authenticate(string $token): JWTSubject
3537
{
3638
$decoded = $this->decode($token);
3739

38-
return $this->authProvider->byId($decoded->sub);
40+
if (!$user = $this->authProvider->byId($decoded->sub)) {
41+
throw new InvalidTokenException();
42+
}
43+
44+
return $user;
3945
}
4046

4147
protected function decode(string $token): mixed

0 commit comments

Comments
 (0)