Refactor TwoFactorIsEnabledQuery to improve handling of users without two-factor providers. Added early exit for users lacking providers and streamlined premium status checks for enabled two-factor authentication.

This commit is contained in:
Rui Tome 2025-12-08 17:39:45 +00:00
parent 245ce712ba
commit 0279cb5e8a
No known key found for this signature in database
GPG Key ID: 526239D96A8EC066

View File

@ -148,9 +148,15 @@ public class TwoFactorIsEnabledQuery : ITwoFactorIsEnabledQuery
foreach (var user in users)
{
var userTwoFactorProviders = usersTwoFactorProvidersMap[user.Id];
var twoFactorIsEnabled = userTwoFactorProviders.Any() &&
(!premiumStatusMap.TryGetValue(user.Id, out var hasPremium) || hasPremium);
if (!userTwoFactorProviders.Any())
{
result.Add((user.Id, false));
continue;
}
// User has providers. If they're in the premium check map, verify premium status
var twoFactorIsEnabled = !premiumStatusMap.TryGetValue(user.Id, out var hasPremium) || hasPremium;
result.Add((user.Id, twoFactorIsEnabled));
}