修改mfa 登录
continuous-integration/drone/push Build is running Details

Uat_IRC_Net8
hang 2025-01-03 10:27:12 +08:00
parent a0b18bbf72
commit 2ac7af44b9
3 changed files with 14 additions and 7 deletions

View File

@ -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;
}
///<summary>UserLogQuery 列表查询参数模型</summary>
public class UserLogQuery : PageInput
{

View File

@ -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<IResponseOutput<LoginReturnDTO>> Login(string userName, string password);
Task<IResponseOutput> VerifyMFACodeAsync(string Code);
Task<IResponseOutput> SendMFAEmail(Guid identityUserId, UserMFAType mfaType = 0);
Task<IResponseOutput> SendMFAEmail(SendMfaCommand sendMfa);
Task<UserBasicInfo> GetUserBasicInfo(Guid userId, string pwd);
Task<IResponseOutput> ModifyPassword(EditPasswordCommand editPwModel);
Task<IResponseOutput> ResetPassword(Guid userId);

View File

@ -735,17 +735,16 @@ namespace IRaCIS.Core.Application.Service
/// <summary>
/// 发送MFA 验证邮件
/// </summary>
/// <param name="identityUserId"></param>
/// <param name="mfaType"></param>
/// <returns></returns>
public async Task<IResponseOutput> SendMFAEmail(Guid identityUserId, UserMFAType mfaType)
public async Task<IResponseOutput> 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 });
}