From 2ac7af44b9d5767204fbb56d773eb9ad01c06201 Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Fri, 3 Jan 2025 10:27:12 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9mfa=20=E7=99=BB=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Service/Management/DTO/UserLogViewModel.cs | 7 +++++++
.../Service/Management/Interface/IUserService.cs | 3 ++-
.../Service/Management/UserService.cs | 11 +++++------
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/IRaCIS.Core.Application/Service/Management/DTO/UserLogViewModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/UserLogViewModel.cs
index ba9937576..9f062599b 100644
--- a/IRaCIS.Core.Application/Service/Management/DTO/UserLogViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Management/DTO/UserLogViewModel.cs
@@ -30,6 +30,13 @@ namespace IRaCIS.Core.Application.ViewModel
public string IPRegion { get; set; }
}
+ public class SendMfaCommand
+ {
+ public Guid IdentityUserId { get; set; }
+
+ public UserMFAType MFAType { get; set; } = UserMFAType.Login;
+ }
+
///UserLogQuery 列表查询参数模型
public class UserLogQuery : PageInput
{
diff --git a/IRaCIS.Core.Application/Service/Management/Interface/IUserService.cs b/IRaCIS.Core.Application/Service/Management/Interface/IUserService.cs
index ff7fe8917..473297ed3 100644
--- a/IRaCIS.Core.Application/Service/Management/Interface/IUserService.cs
+++ b/IRaCIS.Core.Application/Service/Management/Interface/IUserService.cs
@@ -1,4 +1,5 @@
using IRaCIS.Application.Contracts;
+using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Application.Service
@@ -12,7 +13,7 @@ namespace IRaCIS.Core.Application.Service
Task> Login(string userName, string password);
Task VerifyMFACodeAsync(string Code);
- Task SendMFAEmail(Guid identityUserId, UserMFAType mfaType = 0);
+ Task SendMFAEmail(SendMfaCommand sendMfa);
Task GetUserBasicInfo(Guid userId, string pwd);
Task ModifyPassword(EditPasswordCommand editPwModel);
Task ResetPassword(Guid userId);
diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs
index c1fbb25fe..bf7441a9e 100644
--- a/IRaCIS.Core.Application/Service/Management/UserService.cs
+++ b/IRaCIS.Core.Application/Service/Management/UserService.cs
@@ -735,17 +735,16 @@ namespace IRaCIS.Core.Application.Service
///
/// 发送MFA 验证邮件
///
- ///
- ///
+
///
- public async Task SendMFAEmail(Guid identityUserId, UserMFAType mfaType)
+ public async Task SendMFAEmail(SendMfaCommand sendMfa)
{
- identityUserId = identityUserId == Guid.Empty ? _userInfo.IdentityUserId : identityUserId;
+ var identityUserId = sendMfa.IdentityUserId == Guid.Empty ? _userInfo.IdentityUserId : sendMfa.IdentityUserId;
var userInfo = await _identityUserRepository.Where(u => u.Id == identityUserId).Select(t => new { t.FullName, t.EMail }).FirstOrDefaultAsync();
int verificationCode = new Random().Next(100000, 1000000);
- await _mailVerificationService.SenMFAVerifyEmail(identityUserId, userInfo.FullName, userInfo.EMail, verificationCode, (UserMFAType)mfaType);
+ await _mailVerificationService.SenMFAVerifyEmail(identityUserId, userInfo.FullName, userInfo.EMail, verificationCode, sendMfa.MFAType);
var hiddenEmail = IRCEmailPasswordHelper.MaskEmail(userInfo.EMail);
return ResponseOutput.Ok(hiddenEmail);
@@ -1087,7 +1086,7 @@ namespace IRaCIS.Core.Application.Service
else
{
//正常登录才发送邮件
- await SendMFAEmail(identityUserId, UserMFAType.Login);
+ await SendMFAEmail(new SendMfaCommand() { IdentityUserId = identityUserId, MFAType = UserMFAType.Login });
}