Skip to content

Commit 79826c7

Browse files
committed
Expose the jwt invalidate method
1 parent 3910d49 commit 79826c7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/Contracts/AuthJWTInterface.php

+8
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,12 @@ public function changePassword(array $params = [], ?int $userId = null, callable
6161
* @return [bool]
6262
*/
6363
public function verifyToken(string $token, callable $callback = null): bool;
64+
65+
/**
66+
* Invalidate a token.
67+
* @param string $token The user token
68+
* @param bool $isRefresh True if the token is a refresh token
69+
* @return bool
70+
*/
71+
public function invalidate(string $token, bool $isRefresh = false): bool;
6472
}

src/Services/AuthJWTService.php

+14
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,20 @@ public function verifyToken(string $token, callable $callback = null): bool
296296
return true;
297297
}
298298

299+
/**
300+
* Invalidate a token.
301+
* @param string $token The user token
302+
* @param bool $isRefresh True if the token is a refresh token
303+
* @return bool
304+
*/
305+
public function invalidate(string $token, bool $isRefresh = false): bool {
306+
if (empty($token)) {
307+
return true;
308+
}
309+
310+
return $this->jwt->invalidate($token, $isRefresh);
311+
}
312+
299313
/**
300314
* Get a validator for an incoming login request.
301315
*

0 commit comments

Comments
 (0)