Skip to content

Commit 7aa4621

Browse files
authored
Merge pull request #14 from sun-asterisk/enhance.expose_jwt_invalidate_method
Expose the jwt invalidate method
2 parents 3910d49 + 26b585b commit 7aa4621

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-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

+15
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,21 @@ 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+
{
307+
if (empty($token)) {
308+
return true;
309+
}
310+
311+
return $this->jwt->invalidate($token, $isRefresh);
312+
}
313+
299314
/**
300315
* Get a validator for an incoming login request.
301316
*

0 commit comments

Comments
 (0)