diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-01-04 12:20:14 +0100 |
---|---|---|
committer | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2024-01-11 14:02:15 +0100 |
commit | eee9f1eec417c9bb976046e4114d3df943da62e1 (patch) | |
tree | 020456c3a10d45283f02bf32531eab8de330c715 /core | |
parent | 67fba0a574a3740976c84bb6498011e8d2cef0f1 (diff) | |
download | nextcloud-server-eee9f1eec417c9bb976046e4114d3df943da62e1.tar.gz nextcloud-server-eee9f1eec417c9bb976046e4114d3df943da62e1.zip |
Always catch OCP versions of authentication exceptions
And always throw OC versions for BC
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/Controller/AppPasswordController.php | 2 | ||||
-rw-r--r-- | core/Controller/ClientFlowLoginController.php | 5 | ||||
-rw-r--r-- | core/Controller/ClientFlowLoginV2Controller.php | 5 | ||||
-rw-r--r-- | core/Controller/WipeController.php | 2 | ||||
-rw-r--r-- | core/Service/LoginFlowV2Service.php | 2 |
5 files changed, 9 insertions, 7 deletions
diff --git a/core/Controller/AppPasswordController.php b/core/Controller/AppPasswordController.php index 205381e83c1..a4b7791997a 100644 --- a/core/Controller/AppPasswordController.php +++ b/core/Controller/AppPasswordController.php @@ -29,13 +29,13 @@ declare(strict_types=1); namespace OC\Core\Controller; use OC\Authentication\Events\AppPasswordCreatedEvent; -use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\Authentication\Exceptions\CredentialsUnavailableException; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\Authentication\Exceptions\PasswordUnavailableException; use OCP\Authentication\LoginCredentials\IStore; use OCP\EventDispatcher\IEventDispatcher; diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php index 07a78ba368b..57f57bbf887 100644 --- a/core/Controller/ClientFlowLoginController.php +++ b/core/Controller/ClientFlowLoginController.php @@ -33,7 +33,7 @@ namespace OC\Core\Controller; use OC\Authentication\Events\AppPasswordCreatedEvent; -use OC\Authentication\Exceptions\InvalidTokenException; +use OC\Authentication\Exceptions\InvalidTokenException as OcInvalidTokenException; use OC\Authentication\Exceptions\PasswordlessTokenException; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; @@ -47,6 +47,7 @@ use OCP\AppFramework\Http\Attribute\UseSession; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\StandaloneTemplateResponse; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\Defaults; use OCP\EventDispatcher\IEventDispatcher; use OCP\IL10N; @@ -331,7 +332,7 @@ class ClientFlowLoginController extends Controller { try { $token = $this->tokenProvider->getToken($password); if ($token->getLoginName() !== $user) { - throw new InvalidTokenException('login name does not match'); + throw new OcInvalidTokenException('login name does not match'); } } catch (InvalidTokenException $e) { $response = new StandaloneTemplateResponse( diff --git a/core/Controller/ClientFlowLoginV2Controller.php b/core/Controller/ClientFlowLoginV2Controller.php index 8aafabf9892..df522096272 100644 --- a/core/Controller/ClientFlowLoginV2Controller.php +++ b/core/Controller/ClientFlowLoginV2Controller.php @@ -27,7 +27,7 @@ declare(strict_types=1); */ namespace OC\Core\Controller; -use OC\Authentication\Exceptions\InvalidTokenException; +use OC\Authentication\Exceptions\InvalidTokenException as OcInvalidTokenException; use OC\Core\Db\LoginFlowV2; use OC\Core\Exception\LoginFlowV2NotFoundException; use OC\Core\Service\LoginFlowV2Service; @@ -40,6 +40,7 @@ use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\StandaloneTemplateResponse; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\Defaults; use OCP\IL10N; use OCP\IRequest; @@ -211,7 +212,7 @@ class ClientFlowLoginV2Controller extends Controller { try { $token = \OC::$server->get(\OC\Authentication\Token\IProvider::class)->getToken($password); if ($token->getLoginName() !== $user) { - throw new InvalidTokenException('login name does not match'); + throw new OcInvalidTokenException('login name does not match'); } } catch (InvalidTokenException $e) { $response = new StandaloneTemplateResponse( diff --git a/core/Controller/WipeController.php b/core/Controller/WipeController.php index 537fd7126f6..c18b74e4b96 100644 --- a/core/Controller/WipeController.php +++ b/core/Controller/WipeController.php @@ -26,11 +26,11 @@ declare(strict_types=1); */ namespace OC\Core\Controller; -use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\RemoteWipe; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\IRequest; class WipeController extends Controller { diff --git a/core/Service/LoginFlowV2Service.php b/core/Service/LoginFlowV2Service.php index 7e254672ebd..e6a2d93b77d 100644 --- a/core/Service/LoginFlowV2Service.php +++ b/core/Service/LoginFlowV2Service.php @@ -26,7 +26,6 @@ declare(strict_types=1); */ namespace OC\Core\Service; -use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Exceptions\PasswordlessTokenException; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; @@ -37,6 +36,7 @@ use OC\Core\Db\LoginFlowV2Mapper; use OC\Core\Exception\LoginFlowV2NotFoundException; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\IConfig; use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; |