diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 7850b7e38..e2da0075e 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -190,7 +190,7 @@ namespace IRaCIS.Application.Services messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(mfaType == UserMFAType.Login ? EmailBusinessScenario.MFALogin : EmailBusinessScenario.MFAUnlock, messageToSend, emailConfigFunc); - var sucessHandle = GetEmailSuccessHandle(userId, verificationCode); + var sucessHandle = GetEmailSuccessHandle(userId, verificationCode, emailAddress); await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, sucessHandle); @@ -229,7 +229,7 @@ namespace IRaCIS.Application.Services messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.UserResetEmail, messageToSend, emailConfigFunc); - var sucessHandle = GetEmailSuccessHandle(userId, verificationCode); + var sucessHandle = GetEmailSuccessHandle(userId, verificationCode, emailAddress); await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, sucessHandle); @@ -269,7 +269,7 @@ namespace IRaCIS.Application.Services messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.UnloginUseEmailResetPassword, messageToSend, emailConfigFunc); ////此时不知道用户 - var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode); + var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode, emailAddress); await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, sucessHandle); @@ -355,7 +355,7 @@ namespace IRaCIS.Application.Services messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SiteSurveyLogin, messageToSend, emailConfigFunc); //此时不知道用户 - var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode); + var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode, emailAddress); await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, sucessHandle); diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 151b5c907..f103313cf 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -208,6 +208,11 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk(_localizer["User_VerificationCodeExpired"]); } + else if (verificationRecord.EmailOrPhone.Trim() != newEmail.Trim()) + { + //发送验证嘛的和提交的邮箱不一致 + return ResponseOutput.NotOk(_localizer["User_VerificationEmailNotSameWithBefore"]); + } else //验证码正确 并且 没有超时 { @@ -684,7 +689,7 @@ namespace IRaCIS.Application.Services [AllowAnonymous] public async Task VerifyMFACodeAsync(Guid userId, string Code) { - var verificationRecord = await _repository.GetQueryable().OrderByDescending(x => x.ExpirationTime).Where(t => t.UserId == userId && t.Code == Code && t.CodeType == VerifyType.Email).FirstOrDefaultAsync(); + var verificationRecord = await _verificationCodeRepository.Where(t => t.UserId == userId && t.Code == Code && t.CodeType == VerifyType.Email).OrderByDescending(x => x.ExpirationTime).FirstOrDefaultAsync(); VerifyEmialGetDoctorInfoOutDto result = new VerifyEmialGetDoctorInfoOutDto(); //检查数据库是否存在该验证码 @@ -707,6 +712,10 @@ namespace IRaCIS.Application.Services } else //验证码正确 并且 没有超时 { + + + //删除验证码历史记录 + await _verificationCodeRepository.BatchDeleteNoTrackingAsync(t => t.Id == verificationRecord.Id); await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = userId, OptUserId = userId, OptType = UserOptType.MFALogin }, true); } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 9ff013fac..2665746ff 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -117,6 +117,10 @@ namespace IRaCIS.Core.Application.Contracts } else //验证码正确 并且 没有超时 { + + //删除验证码历史记录 + await _repository.BatchDeleteAsync(t => t.Id == verificationRecord.Id); + var dockerInfo = await _repository.Where(t => t.EMail == inDto.EmailOrPhone || t.Phone == inDto.EmailOrPhone).FirstOrDefaultAsync(); if (dockerInfo != null) @@ -192,6 +196,9 @@ namespace IRaCIS.Core.Application.Contracts } else { + //删除验证码历史记录 + await _repository.BatchDeleteAsync(t => t.Id == verifyRecord.Id); + //验证码正确 不处理 }