From 6089848c686fb97d7bb520aca00e029cc924fcd6 Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Fri, 8 Mar 2024 02:19:04 +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/AccessTokenRepository.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/com_oauthserver/site/src/Repository/AccessTokenRepository.php b/com_oauthserver/site/src/Repository/AccessTokenRepository.php index 6b42589..c626911 100644 --- a/com_oauthserver/site/src/Repository/AccessTokenRepository.php +++ b/com_oauthserver/site/src/Repository/AccessTokenRepository.php @@ -42,10 +42,17 @@ class AccessTokenRepository implements AccessTokenRepositoryInterface public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity): void { - /** @var AccessToken $accessTokenEntity */ - $accessToken = $this->accessTokenModel->getItemByIdentifier($accessTokenEntity->getIdentifier()); + $found = false; + try { + /** @var AccessToken $accessTokenEntity */ + $accessToken = $this->accessTokenModel->getItemByIdentifier($accessTokenEntity->getIdentifier()); + if ($accessToken->id > 0) { + $found = true; + } + } catch (\Throwable $e) { + } - if ($accessToken->id > 0) { + if ($found) { throw UniqueTokenIdentifierConstraintViolationException::create(); }