From 0caade0e28e91106d72e0b30c295b955371d4226 Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Tue, 12 Mar 2024 23:25:00 +0300 Subject: [PATCH] throw on save error --- .../site/src/Repository/AccessTokenRepository.php | 7 +++++-- com_oauthserver/site/src/Repository/AuthCodeRepository.php | 7 +++++-- .../site/src/Repository/RefreshTokenRepository.php | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/com_oauthserver/site/src/Repository/AccessTokenRepository.php b/com_oauthserver/site/src/Repository/AccessTokenRepository.php index 382381d..8c32be8 100644 --- a/com_oauthserver/site/src/Repository/AccessTokenRepository.php +++ b/com_oauthserver/site/src/Repository/AccessTokenRepository.php @@ -74,7 +74,10 @@ class AccessTokenRepository implements AccessTokenRepositoryInterface $data['client_id'] = $client->id; unset($data['client_identifier']); - $this->accessTokenModel->save($data); + if (!$this->accessTokenModel->save($data)) + { + throw new \RuntimeException($this->accessTokenModel->getError()); + } } public function revokeAccessToken($tokenId): void @@ -86,7 +89,7 @@ class AccessTokenRepository implements AccessTokenRepositoryInterface * @param string $tokenId * * @throws \Exception - * @since version + * @since version * @noinspection PhpPossiblePolymorphicInvocationInspection */ public function isAccessTokenRevoked($tokenId): bool diff --git a/com_oauthserver/site/src/Repository/AuthCodeRepository.php b/com_oauthserver/site/src/Repository/AuthCodeRepository.php index 4382831..12a020e 100644 --- a/com_oauthserver/site/src/Repository/AuthCodeRepository.php +++ b/com_oauthserver/site/src/Repository/AuthCodeRepository.php @@ -70,7 +70,10 @@ class AuthCodeRepository implements AuthCodeRepositoryInterface $data['client_id'] = $client->id; unset($data['client_identifier']); - $this->authCodeModel->save($data); + if (!$this->authCodeModel->save($data)) + { + throw new \RuntimeException($this->authCodeModel->getError()); + } } public function revokeAuthCode($codeId): void @@ -82,7 +85,7 @@ class AuthCodeRepository implements AuthCodeRepositoryInterface * @param string $codeId * * @throws \Exception - * @since version + * @since version * @noinspection PhpPossiblePolymorphicInvocationInspection */ public function isAuthCodeRevoked($codeId): bool diff --git a/com_oauthserver/site/src/Repository/RefreshTokenRepository.php b/com_oauthserver/site/src/Repository/RefreshTokenRepository.php index 339e2d2..1f5e751 100644 --- a/com_oauthserver/site/src/Repository/RefreshTokenRepository.php +++ b/com_oauthserver/site/src/Repository/RefreshTokenRepository.php @@ -72,7 +72,10 @@ class RefreshTokenRepository implements RefreshTokenRepositoryInterface unset($data['access_token_identifier']); $data['access_token_id'] = $accessToken->id; - $this->refreshTokenModel->save($data); + if (!$this->refreshTokenModel->save($data)) + { + throw new \RuntimeException($this->refreshTokenModel->getError()); + } } public function revokeRefreshToken($tokenId): void @@ -84,7 +87,7 @@ class RefreshTokenRepository implements RefreshTokenRepositoryInterface * @param string $tokenId * * @throws \Exception - * @since version + * @since version * @noinspection PhpPossiblePolymorphicInvocationInspection */ public function isRefreshTokenRevoked($tokenId): bool