diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2024-10-28 10:15:16 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-11-05 10:50:29 +0000 |
commit | fcefd37a5f7e24208a115214660d419cbdeae7f3 (patch) | |
tree | 08a9e085d2ddeb0c4ddf420724eabee036ac8a83 /lib/private | |
parent | c7b5c3e02f1d2f9d7dc49ee094cc4420673f4e9b (diff) | |
download | nextcloud-server-fcefd37a5f7e24208a115214660d419cbdeae7f3.tar.gz nextcloud-server-fcefd37a5f7e24208a115214660d419cbdeae7f3.zip |
fix: Handle exception when clearing previously removed two factor tokensbackport/48933/stable30
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')
-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 f4b3b88c50b..39d886132dd 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) { + } } } } |