Skip to content

Commit fe9a0fd

Browse files
committed
feat(auth): dispatch new TokenInvalidatedEvent when PublicKeyTokenProvider::invalidateToken is called
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent a41c404 commit fe9a0fd

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

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)