Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(auth): include the token entity in TokenInvalidatedEvent
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Aug 21, 2025
commit 3d368342846cfc28299b6d93cdc83c0b50a6e173
4 changes: 2 additions & 2 deletions lib/private/Authentication/Token/PublicKeyTokenProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function invalidateToken(string $token) {
$this->mapper->invalidate($this->hashTokenWithEmptySecret($token));
$this->cacheInvalidHash($tokenHash);
if ($tokenEntry !== null) {
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($tokenEntry->getUID(), $tokenEntry->getId()));
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($tokenEntry));
}
}

Expand All @@ -290,7 +290,7 @@ public function invalidateTokenById(string $uid, int $id) {
}
$this->mapper->invalidate($token->getToken());
$this->cacheInvalidHash($token->getToken());
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($uid, $id));
$this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($token));
}

public function invalidateOldTokens() {
Expand Down
19 changes: 5 additions & 14 deletions lib/public/Authentication/Events/TokenInvalidatedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
namespace OCP\Authentication\Events;

use OCP\Authentication\Token\IToken;
use OCP\EventDispatcher\Event;

/**
Expand All @@ -21,27 +22,17 @@ class TokenInvalidatedEvent extends Event {
* @since 32.0.0
*/
public function __construct(
private string $userId,
private int $tokenId,
private IToken $token,
) {
parent::__construct();
}

/**
* returns the uid of the user associated with the invalidated token
* returns the token that has been invalidated
*
* @since 32.0.0
*/
public function getUserId(): string {
return $this->userId;
}

/**
* returns the ID of the token that is being invalidated
*
* @since 32.0.0
*/
public function getTokenId(): int {
return $this->tokenId;
public function getToken(): IToken {
return $this->token;
}
}
Loading