mapper->findExpired($time) as $mapping) { $this->revokeMapping($mapping); } } /** * Revoke every access token issued for the given refresh token. Tolerates * the duplicate rows a concurrent exchange can leave behind. */ public function revokeByRefreshToken(string $refreshToken): void { foreach ($this->mapper->findAllByRefreshToken($refreshToken) as $mapping) { $this->revokeMapping($mapping); } } private function revokeMapping(OcmTokenMap $mapping): void { $this->revokeAccessToken($mapping->getAccessTokenId()); $this->mapper->delete($mapping); } /** * Delete the access token from oc_authtoken. getTokenById throws for an * expired token but still carries it, so the owner uid required by * invalidateTokenById is recoverable. */ private function revokeAccessToken(int $accessTokenId): void { try { $token = $this->tokenProvider->getTokenById($accessTokenId); } catch (ExpiredTokenException|WipeTokenException $e) { $token = $e->getToken(); } catch (InvalidTokenException) { // Access token already gone; nothing left to revoke. return; } $this->tokenProvider->invalidateTokenById($token->getUID(), $accessTokenId); } }