Skip to content

Commit 3d36834

Browse files
committed
feat(auth): include the token entity in TokenInvalidatedEvent
Signed-off-by: Julien Veyssier <[email protected]>
1 parent 4a35837 commit 3d36834

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

lib/private/Authentication/Token/PublicKeyTokenProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function invalidateToken(string $token) {
279279
$this->mapper->invalidate($this->hashTokenWithEmptySecret($token));
280280
$this->cacheInvalidHash($tokenHash);
281281
if ($tokenEntry !== null) {
282-
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($tokenEntry->getUID(), $tokenEntry->getId()));
282+
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($tokenEntry));
283283
}
284284
}
285285

@@ -290,7 +290,7 @@ public function invalidateTokenById(string $uid, int $id) {
290290
}
291291
$this->mapper->invalidate($token->getToken());
292292
$this->cacheInvalidHash($token->getToken());
293-
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($uid, $id));
293+
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($token));
294294
}
295295

296296
public function invalidateOldTokens() {

lib/public/Authentication/Events/TokenInvalidatedEvent.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
namespace OCP\Authentication\Events;
1010

11+
use OCP\Authentication\Token\IToken;
1112
use OCP\EventDispatcher\Event;
1213

1314
/**
@@ -21,27 +22,17 @@ class TokenInvalidatedEvent extends Event {
2122
* @since 32.0.0
2223
*/
2324
public function __construct(
24-
private string $userId,
25-
private int $tokenId,
25+
private IToken $token,
2626
) {
2727
parent::__construct();
2828
}
2929

3030
/**
31-
* returns the uid of the user associated with the invalidated token
31+
* returns the token that has been invalidated
3232
*
3333
* @since 32.0.0
3434
*/
35-
public function getUserId(): string {
36-
return $this->userId;
37-
}
38-
39-
/**
40-
* returns the ID of the token that is being invalidated
41-
*
42-
* @since 32.0.0
43-
*/
44-
public function getTokenId(): int {
45-
return $this->tokenId;
35+
public function getToken(): IToken {
36+
return $this->token;
4637
}
4738
}

0 commit comments

Comments
 (0)