diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-01-04 12:20:14 +0100 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2024-01-11 18:00:59 +0000 |
commit | 360e7ffcca0940400317d238cfce751b6b10d058 (patch) | |
tree | 62b3ef5224cd966a02291f63363fb6b75eb850c9 /apps/settings/lib | |
parent | 2b378f6ab2a64a4a22ebbb9883883116aa1de0fa (diff) | |
download | nextcloud-server-360e7ffcca0940400317d238cfce751b6b10d058.tar.gz nextcloud-server-360e7ffcca0940400317d238cfce751b6b10d058.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 'apps/settings/lib')
-rw-r--r-- | apps/settings/lib/Controller/AuthSettingsController.php | 12 | ||||
-rw-r--r-- | apps/settings/lib/Settings/Personal/Security/Authtokens.php | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/apps/settings/lib/Controller/AuthSettingsController.php b/apps/settings/lib/Controller/AuthSettingsController.php index c0dc8cbac85..cfff6582074 100644 --- a/apps/settings/lib/Controller/AuthSettingsController.php +++ b/apps/settings/lib/Controller/AuthSettingsController.php @@ -32,10 +32,8 @@ namespace OCA\Settings\Controller; use BadMethodCallException; -use OC\Authentication\Exceptions\ExpiredTokenException; -use OC\Authentication\Exceptions\InvalidTokenException; +use OC\Authentication\Exceptions\InvalidTokenException as OcInvalidTokenException; use OC\Authentication\Exceptions\PasswordlessTokenException; -use OC\Authentication\Exceptions\WipeTokenException; use OC\Authentication\Token\INamedToken; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; @@ -45,6 +43,9 @@ use OCP\Activity\IManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; +use OCP\Authentication\Exceptions\ExpiredTokenException; +use OCP\Authentication\Exceptions\InvalidTokenException; +use OCP\Authentication\Exceptions\WipeTokenException; use OCP\IRequest; use OCP\ISession; use OCP\IUserSession; @@ -292,7 +293,8 @@ class AuthSettingsController extends Controller { $token = $e->getToken(); } if ($token->getUID() !== $this->uid) { - throw new InvalidTokenException('This token does not belong to you!'); + /* We have to throw the OC version so both OC and OCP catches catch it */ + throw new OcInvalidTokenException('This token does not belong to you!'); } return $token; } @@ -305,7 +307,7 @@ class AuthSettingsController extends Controller { * @param int $id * @return JSONResponse * @throws InvalidTokenException - * @throws \OC\Authentication\Exceptions\ExpiredTokenException + * @throws ExpiredTokenException */ public function wipe(int $id): JSONResponse { if ($this->checkAppToken()) { diff --git a/apps/settings/lib/Settings/Personal/Security/Authtokens.php b/apps/settings/lib/Settings/Personal/Security/Authtokens.php index e713344ce88..9a7405fb7a2 100644 --- a/apps/settings/lib/Settings/Personal/Security/Authtokens.php +++ b/apps/settings/lib/Settings/Personal/Security/Authtokens.php @@ -25,12 +25,12 @@ declare(strict_types=1); */ namespace OCA\Settings\Settings\Personal\Security; -use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\INamedToken; use OC\Authentication\Token\IProvider as IAuthTokenProvider; use OC\Authentication\Token\IToken; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Services\IInitialState; +use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\ISession; use OCP\IUserSession; use OCP\Session\Exceptions\SessionNotAvailableException; |