aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2021-12-01 18:38:24 +0100
committerGitHub <noreply@github.com>2021-12-01 18:38:24 +0100
commitc21173ff2714e6c5ef0470cf3bc0efd57d98f291 (patch)
treed266f3d9b17c92348bb9331a42c37a489a21c163
parent977cea1ee2f3ec627fcb190d32740c62c04adfde (diff)
parent660e5502603e82bb70652cbd146d72139791d6a7 (diff)
downloadnextcloud-server-c21173ff2714e6c5ef0470cf3bc0efd57d98f291.tar.gz
nextcloud-server-c21173ff2714e6c5ef0470cf3bc0efd57d98f291.zip
Merge pull request #30012 from nextcloud/bugfix/noid/only-check-2fa-state-once
-rw-r--r--lib/private/Authentication/TwoFactorAuth/Manager.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/private/Authentication/TwoFactorAuth/Manager.php b/lib/private/Authentication/TwoFactorAuth/Manager.php
index 375803b1d96..66e7c090e42 100644
--- a/lib/private/Authentication/TwoFactorAuth/Manager.php
+++ b/lib/private/Authentication/TwoFactorAuth/Manager.php
@@ -87,6 +87,9 @@ class Manager {
/** @var EventDispatcherInterface */
private $legacyDispatcher;
+ /** @psalm-var array<string, bool> */
+ private $userIsTwoFactorAuthenticated = [];
+
public function __construct(ProviderLoader $providerLoader,
IRegistry $providerRegistry,
MandatoryTwoFactor $mandatoryTwoFactor,
@@ -118,6 +121,10 @@ class Manager {
* @return boolean
*/
public function isTwoFactorAuthenticated(IUser $user): bool {
+ if (isset($this->userIsTwoFactorAuthenticated[$user->getUID()])) {
+ return $this->userIsTwoFactorAuthenticated[$user->getUID()];
+ }
+
if ($this->mandatoryTwoFactor->isEnforcedFor($user)) {
return true;
}
@@ -129,7 +136,8 @@ class Manager {
$providerIds = array_keys($enabled);
$providerIdsWithoutBackupCodes = array_diff($providerIds, [self::BACKUP_CODES_PROVIDER_ID]);
- return !empty($providerIdsWithoutBackupCodes);
+ $this->userIsTwoFactorAuthenticated[$user->getUID()] = !empty($providerIdsWithoutBackupCodes);
+ return $this->userIsTwoFactorAuthenticated[$user->getUID()];
}
/**