Skip to content

Commit 7184eb6

Browse files
committed
Updated Tymon's JWTAuth and improved the authentication process.
Signed-off-by: Jason Lewis <[email protected]>
1 parent 1e9320d commit 7184eb6

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

changes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
### v0.8.*@dev (master)
22

3+
##### General
4+
5+
- Updated Tymon's JWTAuth to the latest version, `0.4.1`.
6+
37
##### Added
48

59
- Can now use `RateLimiter::setRateLimiter` to change the key used to rate limit requests from the clients IP.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"require-dev": {
1818
"lucadegasperi/oauth2-server-laravel": "3.0.*",
19-
"tymon/jwt-auth": "0.3.*",
19+
"tymon/jwt-auth": "0.4.*",
2020
"illuminate/routing": "4.2.*",
2121
"illuminate/events": "4.2.*",
2222
"illuminate/auth": "4.2.*",

src/Auth/JWTProvider.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ public function authenticate(Request $request, Route $route)
4343
$token = $this->getToken($request);
4444

4545
try {
46-
return $this->auth->login($token);
47-
} catch (JWTException $e) {
48-
throw new UnauthorizedHttpException('JWTAuth', $e->getMessage());
46+
if (! $user = $this->auth->authenticate($token)) {
47+
throw new UnauthorizedHttpException('JWTAuth', 'Unable authenticate with invalid token.');
48+
}
49+
} catch (JWTException $exception) {
50+
throw new UnauthorizedHttpException('JWTAuth', $exception->getMessage());
4951
}
52+
53+
return $user;
5054
}
5155

5256
/**

0 commit comments

Comments
 (0)