From 9cda4360ca6c829c3d610fc48cb4ec972457fead Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Mon, 20 Oct 2025 13:40:52 +0800
Subject: [PATCH] =?UTF-8?q?MFA=20=E9=9C=80=E6=B1=82=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Service/Management/UserService.cs | 14 ++++++++++----
IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs | 2 ++
IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs | 18 ++++++++++++++++++
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs
index d0b4ef427..1b96ec5cf 100644
--- a/IRaCIS.Core.Application/Service/Management/UserService.cs
+++ b/IRaCIS.Core.Application/Service/Management/UserService.cs
@@ -825,9 +825,10 @@ namespace IRaCIS.Core.Application.Service
/// 验证MFA 邮件
///
///
+ ///
///
///
- public async Task VerifyMFACodeAsync(string Code)
+ public async Task VerifyMFACodeAsync(string Code, bool isRemember)
{
var identityUserId = _userInfo.IdentityUserId;
@@ -857,7 +858,12 @@ namespace IRaCIS.Core.Application.Service
}
}
- await _fusionCache.SetAsync(CacheKeys.UserMFAVerifyPass(identityUserId), true, TimeSpan.FromDays(_serviceVerifyConfigConfig.UserMFAVerifyDays));
+ if (isRemember)
+ {
+ await _fusionCache.SetAsync(CacheKeys.UserMFAVerifyPass(identityUserId), _userInfo.BrowserFingerprint, TimeSpan.FromDays(_serviceVerifyConfigConfig.UserMFAVerifyDays));
+
+ }
+
return ResponseOutput.Ok();
}
@@ -1044,7 +1050,7 @@ namespace IRaCIS.Core.Application.Service
var lastLoginIPRegion = await _userLogRepository.Where(t => t.ActionUserName == actionUserName && userOptTypes.Contains(t.OptType))
.OrderByDescending(t => t.CreateTime).Select(t => t.IPRegion).FirstOrDefaultAsync();
- if (lastLoginIPRegion!=null&&lastLoginIPRegion != string.Empty)
+ if (lastLoginIPRegion != null && lastLoginIPRegion != string.Empty)
{
// 与上一次区域不一致
//if (SplitAndConcatenate(existUserLoginInfo.LastLoginIP) != SplitAndConcatenate(iPRegion))
@@ -1122,7 +1128,7 @@ namespace IRaCIS.Core.Application.Service
if (_verifyConfig.CurrentValue.OpenLoginMFA)
{
- if ((await _fusionCache.GetOrDefaultAsync(CacheKeys.UserMFAVerifyPass(identityUserId), false)) == true)
+ if ((await _fusionCache.GetOrDefaultAsync(CacheKeys.UserMFAVerifyPass(identityUserId), "")) == _userInfo.BrowserFingerprint)
{
userLoginReturnModel.IsMFA = false;
}
diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs
index 3c146fb3c..c3391264b 100644
--- a/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs
+++ b/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs
@@ -55,5 +55,7 @@
/// 字符串形式 标识时区
///
string TimeZoneId { get; }
+
+ string BrowserFingerprint { get; }
}
}
diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs
index d994ad54a..2fe9e9723 100644
--- a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs
+++ b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs
@@ -300,6 +300,24 @@ namespace IRaCIS.Core.Domain.Share
}
}
+ public string BrowserFingerprint
+ {
+ get
+ {
+ var browserFingerprint = _accessor?.HttpContext?.Request?.Headers["BrowserFingerprint"];
+
+ if (browserFingerprint is not null && !string.IsNullOrEmpty(browserFingerprint.Value))
+ {
+ return browserFingerprint.Value;
+ }
+
+ //return "Etc/UTC";
+ return Guid.NewGuid().ToString();
+
+
+ }
+ }
+
public Guid? SignId
{