refreshTokenModel = $refreshTokenModel; $this->accessTokenModel = $accessTokenModel; } public function getNewRefreshToken(): RefreshToken { return new RefreshToken(); } public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshTokenEntity) { $refreshToken = $this->refreshTokenModel->getItemByIdentifier($refreshTokenEntity->getIdentifier()); if ($refreshToken->id > 0) { throw UniqueTokenIdentifierConstraintViolationException::create(); } $data = $refreshTokenEntity->getData(); $accessToken = $this->accessTokenModel->getItemByIdentifier($refreshTokenEntity->getAccessToken()); unset($data['access_token_identifier']); $data['access_token_id'] = $accessToken->id; $this->refreshTokenModel->save($data); } public function revokeRefreshToken($tokenId): void { $this->refreshTokenModel->revoke($tokenId); } public function isRefreshTokenRevoked($tokenId): bool { $refreshToken = $this->refreshTokenModel->getItemByIdentifier($tokenId); if (empty($refreshToken->id)) { return true; } return !!$refreshToken->revoked; } }