diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-01-28 16:12:06 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-01-29 13:08:56 +0100 |
commit | ac8a6e22448cd4077e73b68731764bd60775665a (patch) | |
tree | b1702be7456cc7e5765eafebbc02fac6ff639752 /lib/private/Authentication/TwoFactorAuth | |
parent | 8d52a3ac4a9f13c7ff7197b80ba055f37ac575d3 (diff) | |
download | nextcloud-server-ac8a6e22448cd4077e73b68731764bd60775665a.tar.gz nextcloud-server-ac8a6e22448cd4077e73b68731764bd60775665a.zip |
Clean pending 2FA authentication on password reset
When a password is reste we should make sure that all users are properly
logged in. Pending states should be cleared. For example a session where
the 2FA code is not entered yet should be cleared.
The token is now removed so the session will be killed the next time
this is checked (within 5 minutes).
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Authentication/TwoFactorAuth')
-rw-r--r-- | lib/private/Authentication/TwoFactorAuth/Manager.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/private/Authentication/TwoFactorAuth/Manager.php b/lib/private/Authentication/TwoFactorAuth/Manager.php index 56fca8a745c..ef95184aba7 100644 --- a/lib/private/Authentication/TwoFactorAuth/Manager.php +++ b/lib/private/Authentication/TwoFactorAuth/Manager.php @@ -31,6 +31,7 @@ use function array_diff; use function array_filter; use BadMethodCallException; use Exception; +use OC\Authentication\Exceptions\ExpiredTokenException; use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\IProvider as TokenProvider; use OCP\Activity\IManager; @@ -364,4 +365,12 @@ class Manager { $this->config->setUserValue($user->getUID(), 'login_token_2fa', $token->getId(), $this->timeFactory->getTime()); } + public function clearTwoFactorPending(string $userId) { + $tokensNeeding2FA = $this->config->getUserKeys($userId, 'login_token_2fa'); + + foreach ($tokensNeeding2FA as $tokenId) { + $this->tokenProvider->invalidateTokenById($userId, $tokenId); + } + } + } |