Merge pull request #4948 from zyhfish/task/fix-4947

Fix #4947: check the 2FA settings.
This commit is contained in:
Shaun Walker 2024-12-24 08:46:43 -05:00 committed by GitHub
commit d19d7d2a43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -512,7 +512,10 @@ namespace Oqtane.Managers
user = _users.GetUser(user.Username);
if (user != null)
{
if (user.TwoFactorRequired && user.TwoFactorCode == token && DateTime.UtcNow < user.TwoFactorExpiry)
var alias = _tenantManager.GetAlias();
var twoFactorSetting = _settings.GetSetting(EntityNames.Site, alias.SiteId, "LoginOptions:TwoFactor")?.SettingValue ?? "false";
var twoFactorRequired = twoFactorSetting == "required" || user.TwoFactorRequired;
if (twoFactorRequired && user.TwoFactorCode == token && DateTime.UtcNow < user.TwoFactorExpiry)
{
user.IsAuthenticated = true;
}