diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 3cdef44cb..55e0fa0f3 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -12065,7 +12065,7 @@ - + 保存表格问题标记 diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index dc43fb811..670b21983 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -303,7 +303,7 @@ namespace IRaCIS.Core.Application.Service await _fusionCache.RemoveAsync(CacheKeys.UserLoginError(userName)); - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = _userInfo.IdentityUserId, OptType = UserOptType.ResetPassword }, true); + await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.ResetPassword }, true); return ResponseOutput.Ok(); } @@ -413,7 +413,7 @@ namespace IRaCIS.Core.Application.Service IsFirstAdd = false }); - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = identityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.LoginModifyPassword }, true); + await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = identityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.UnloginModifyPasswoed }, true); return ResponseOutput.Ok(); @@ -605,7 +605,7 @@ namespace IRaCIS.Core.Application.Service if (user.Status != model.Status) { - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, OptType = model.Status == UserStateEnum.Enable ? UserOptType.AccountEnable : UserOptType.AccountLocked }, true); + await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = model.Id, OptType = model.Status == UserStateEnum.Enable ? UserOptType.AccountEnable : UserOptType.AccountLocked }, true); } @@ -735,17 +735,17 @@ namespace IRaCIS.Core.Application.Service /// /// 发送MFA 验证邮件 /// - /// + /// /// /// [AllowAnonymous] - public async Task SendMFAEmail(Guid userId, UserMFAType mfaType) + public async Task SendMFAEmail(Guid identityUserId, UserMFAType mfaType) { - var userInfo = await _identityUserRepository.Where(u => u.Id == userId).Select(t => new { t.FullName, t.EMail }).FirstOrDefaultAsync(); + 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(userId, userInfo.FullName, userInfo.EMail, verificationCode, (UserMFAType)mfaType); + await _mailVerificationService.SenMFAVerifyEmail(identityUserId, userInfo.FullName, userInfo.EMail, verificationCode, (UserMFAType)mfaType); var hiddenEmail = IRCEmailPasswordHelper.MaskEmail(userInfo.EMail); return ResponseOutput.Ok(hiddenEmail); @@ -754,20 +754,19 @@ namespace IRaCIS.Core.Application.Service /// /// 验证MFA 邮件 /// - /// + /// /// /// /// - [AllowAnonymous] - public async Task VerifyMFACodeAsync(Guid userId, string Code) + public async Task VerifyMFACodeAsync(Guid identityUserId, string Code) { - var verificationRecord = await _verificationCodeRepository.Where(t => t.UserId == userId && t.Code == Code && t.CodeType == VerifyType.Email).OrderByDescending(x => x.ExpirationTime).FirstOrDefaultAsync(); + var verificationRecord = await _verificationCodeRepository.Where(t => t.UserId == identityUserId && t.Code == Code && t.CodeType == VerifyType.Email).OrderByDescending(x => x.ExpirationTime).FirstOrDefaultAsync(); VerifyEmialGetDoctorInfoOutDto result = new VerifyEmialGetDoctorInfoOutDto(); //检查数据库是否存在该验证码 if (verificationRecord == null) { - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = userId, OptUserId = userId, OptType = UserOptType.MFALoginFail }, true); + await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.MFALoginFail }, true); //---验证码错误。 throw new BusinessValidationFailedException(_localizer["TrialSiteSurvey_WrongVerificationCode"]); } @@ -776,7 +775,7 @@ namespace IRaCIS.Core.Application.Service //检查验证码是否失效 if (verificationRecord.ExpirationTime < DateTime.Now) { - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = userId, OptUserId = userId, OptType = UserOptType.MFALoginFail }, true); + await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.MFALoginFail }, true); //---验证码已经过期。 throw new BusinessValidationFailedException(_localizer["TrialSiteSurvey_ExpiredVerificationCode"]); @@ -788,7 +787,7 @@ namespace IRaCIS.Core.Application.Service //删除验证码历史记录 await _verificationCodeRepository.BatchDeleteNoTrackingAsync(t => t.Id == verificationRecord.Id); - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = userId, OptUserId = userId, OptType = UserOptType.MFALogin }, true); + await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.MFALogin }, true); } } @@ -1083,7 +1082,7 @@ namespace IRaCIS.Core.Application.Service userLoginReturnModel.BasicInfo.EMail = hiddenEmail; - //修改密码 + //修改密码 || 90天修改密码再mfa 之前 if (userLoginReturnModel.BasicInfo.IsFirstAdd || userLoginReturnModel.BasicInfo.LoginState == 1) { //userLoginReturnModel.JWTStr = _tokenService.GetToken(userLoginReturnModel.BasicInfo); diff --git a/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs b/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs index 2966cf8d1..ca7dd488a 100644 --- a/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/BeforeSaveTrigger/UserLogTrigger.cs @@ -36,7 +36,7 @@ namespace IRaCIS.Core.Application.Triggers if (context.ChangeType == ChangeType.Added) { - await _userLogReposiotry.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, OptType = UserOptType.AddUser }, true); + await _userLogReposiotry.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = user.Id, OptType = UserOptType.AddUser }, true); }