diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2024-10-28 10:15:16 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-11-05 11:14:05 +0100 |
commit | 5ea5b2de84fe21da0b3140d1df06f5098aa389a5 (patch) | |
tree | 9c1ccaf97dc5235aac8c90b66a7ab68a80983017 /lib/private/Authentication | |
parent | 381a2aa627dc99a353b9f6b4a75677811ee7d22b (diff) | |
download | nextcloud-server-5ea5b2de84fe21da0b3140d1df06f5098aa389a5.tar.gz nextcloud-server-5ea5b2de84fe21da0b3140d1df06f5098aa389a5.zip |
fix: Handle exception when clearing previously removed two factor tokensclear-pending-two-factor-tokens-also-from-configuration
If a token was already removed from the database but not from the
configuration clearing the tokens will try to remove it again from the
database, which caused a DoesNotExistException to be thrown.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'lib/private/Authentication')
-rw-r--r-- | lib/private/Authentication/TwoFactorAuth/Manager.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/private/Authentication/TwoFactorAuth/Manager.php b/lib/private/Authentication/TwoFactorAuth/Manager.php index 74a19ebc718..1b22300e317 100644 --- a/lib/private/Authentication/TwoFactorAuth/Manager.php +++ b/lib/private/Authentication/TwoFactorAuth/Manager.php @@ -12,6 +12,7 @@ use BadMethodCallException; use Exception; use OC\Authentication\Token\IProvider as TokenProvider; use OCP\Activity\IManager; +use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Authentication\Exceptions\InvalidTokenException; use OCP\Authentication\TwoFactorAuth\IActivatableAtLogin; @@ -368,7 +369,10 @@ class Manager { foreach ($tokensNeeding2FA as $tokenId) { $this->config->deleteUserValue($userId, 'login_token_2fa', $tokenId); - $this->tokenProvider->invalidateTokenById($userId, (int)$tokenId); + try { + $this->tokenProvider->invalidateTokenById($userId, (int)$tokenId); + } catch (DoesNotExistException $e) { + } } } } |