/** @var EventDispatcherInterface */
private $legacyDispatcher;
+ /** @psalm-var array<string, bool> */
+ private $userIsTwoFactorAuthenticated = [];
+
public function __construct(ProviderLoader $providerLoader,
IRegistry $providerRegistry,
MandatoryTwoFactor $mandatoryTwoFactor,
* @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;
}
$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()];
}
/**