Skip to content

Commit 3da919c

Browse files
committed
feat(auth): dispatch new TokenInvalidatedEvent when PublicKeyTokenProvider::invalidateToken is called
Signed-off-by: Julien Veyssier <[email protected]>
1 parent 8ffd30b commit 3da919c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/private/Authentication/Token/PublicKeyTokenProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,16 @@ public function renewSessionToken(string $oldSessionId, string $sessionId): OCPI
270270

271271
public function invalidateToken(string $token) {
272272
$tokenHash = $this->hashToken($token);
273+
$tokenEntry = null;
274+
try {
275+
$tokenEntry = $this->mapper->getToken($tokenHash);
276+
} catch (DoesNotExistException) {}
273277
$this->mapper->invalidate($this->hashToken($token));
274278
$this->mapper->invalidate($this->hashTokenWithEmptySecret($token));
275279
$this->cacheInvalidHash($tokenHash);
280+
if ($tokenEntry !== null) {
281+
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($tokenEntry->getUID(), $tokenEntry->getId()));
282+
}
276283
}
277284

278285
public function invalidateTokenById(string $uid, int $id) {

0 commit comments

Comments
 (0)