1515use OCP \AppFramework \Db \DoesNotExistException ;
1616use OCP \AppFramework \Db \TTransactional ;
1717use OCP \AppFramework \Utility \ITimeFactory ;
18+ use OCP \Authentication \Events \TokenInvalidatedEvent ;
1819use OCP \Authentication \Token \IToken as OCPIToken ;
20+ use OCP \EventDispatcher \IEventDispatcher ;
1921use OCP \ICache ;
2022use OCP \ICacheFactory ;
2123use OCP \IConfig ;
@@ -55,14 +57,18 @@ class PublicKeyTokenProvider implements IProvider {
5557 /** @var IHasher */
5658 private $ hasher ;
5759
60+ private IEventDispatcher $ eventDispatcher ;
61+
5862 public function __construct (PublicKeyTokenMapper $ mapper ,
5963 ICrypto $ crypto ,
6064 IConfig $ config ,
6165 IDBConnection $ db ,
6266 LoggerInterface $ logger ,
6367 ITimeFactory $ time ,
6468 IHasher $ hasher ,
65- ICacheFactory $ cacheFactory ) {
69+ ICacheFactory $ cacheFactory ,
70+ IEventDispatcher $ eventDispatcher ,
71+ ) {
6672 $ this ->mapper = $ mapper ;
6773 $ this ->crypto = $ crypto ;
6874 $ this ->config = $ config ;
@@ -74,6 +80,7 @@ public function __construct(PublicKeyTokenMapper $mapper,
7480 ? $ cacheFactory ->createLocal ('authtoken_ ' )
7581 : $ cacheFactory ->createInMemory ();
7682 $ this ->hasher = $ hasher ;
83+ $ this ->eventDispatcher = $ eventDispatcher ;
7784 }
7885
7986 /**
@@ -275,7 +282,7 @@ public function invalidateTokenById(string $uid, int $id) {
275282 }
276283 $ this ->mapper ->invalidate ($ token ->getToken ());
277284 $ this ->cacheInvalidHash ($ token ->getToken ());
278-
285+ $ this -> eventDispatcher -> dispatchTyped ( new TokenInvalidatedEvent ( $ uid , $ id ));
279286 }
280287
281288 public function invalidateOldTokens () {
0 commit comments