From 78486a87a81f4e39da6630d3b3079550f2db02e6 Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Fri, 8 Mar 2024 02:18:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83?= =?UTF-8?q?=20=D0=BD=D0=B0=20try/catch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../site/src/Repository/RefreshTokenRepository.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/com_oauthserver/site/src/Repository/RefreshTokenRepository.php b/com_oauthserver/site/src/Repository/RefreshTokenRepository.php index 704f612..91e6819 100644 --- a/com_oauthserver/site/src/Repository/RefreshTokenRepository.php +++ b/com_oauthserver/site/src/Repository/RefreshTokenRepository.php @@ -35,15 +35,23 @@ class RefreshTokenRepository implements RefreshTokenRepositoryInterface public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshTokenEntity) { - $refreshToken = $this->refreshTokenModel->getItemByIdentifier($refreshTokenEntity->getIdentifier()); + $found = false; + try { + $refreshToken = $this->refreshTokenModel->getItemByIdentifier($refreshTokenEntity->getIdentifier()); - if ($refreshToken->id > 0) { + if ($refreshToken->id > 0) { + $found = true; + } + } catch (\Exception $e) { + } + + if ($found) { throw UniqueTokenIdentifierConstraintViolationException::create(); } $data = $refreshTokenEntity->getData(); - $accessToken = $this->accessTokenModel->getItemByIdentifier($refreshTokenEntity->getAccessToken()); + $accessToken = $this->accessTokenModel->getItemByIdentifier($refreshTokenEntity->getAccessToken()->getIdentifier()); unset($data['access_token_identifier']); $data['access_token_id'] = $accessToken->id;