diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index b4e7d958e..e14ac2980 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -2354,6 +2354,13 @@
发送验证码 修改邮箱(已经登陆修改) New
+
+
+ Result 为true 的时候 允许提交设置
+
+
+
+
重置密码为 默认密码
diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs
index 0f021e330..2d4fbbbaf 100644
--- a/IRaCIS.Core.Application/Service/Common/MailService.cs
+++ b/IRaCIS.Core.Application/Service/Common/MailService.cs
@@ -278,6 +278,8 @@ namespace IRaCIS.Application.Services
var token = _tokenService.GetToken(IRaCISClaims.Create(_mapper.Map(sysUserInfo)));
+ await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token });
+
routeUrl = routeUrl + "?UserId=" + sysUserInfo.Id + "&Email=" + sysUserInfo.EMail + "&UserName=" + sysUserInfo.UserName + "&UserType=" + sysUserInfo.UserTypeRole.UserTypeShortName + "&access_token=" + token;
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
@@ -369,6 +371,11 @@ namespace IRaCIS.Application.Services
var token = _tokenService.GetToken(IRaCISClaims.Create(_mapper.Map(sysUserInfo)));
+ if (sysUserInfo.IsFirstAdd)
+ {
+ await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token });
+ }
+
var pathToFile = _hostEnvironment.WebRootPath
+ Path.DirectorySeparatorChar.ToString()
@@ -421,6 +428,10 @@ namespace IRaCIS.Application.Services
var token = _tokenService.GetToken(IRaCISClaims.Create(_mapper.Map(sysUserInfo)));
+ if (sysUserInfo.IsFirstAdd)
+ {
+ await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token });
+ }
var pathToFile = _hostEnvironment.WebRootPath
+ Path.DirectorySeparatorChar.ToString()
diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs
index 45b54d716..b6e7630ae 100644
--- a/IRaCIS.Core.Application/Service/Management/UserService.cs
+++ b/IRaCIS.Core.Application/Service/Management/UserService.cs
@@ -199,17 +199,30 @@ namespace IRaCIS.Application.Services
return ResponseOutput.Ok();
}
-
-
+ ///
+ /// Result 为true 的时候 允许提交设置
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task VerifyCanInitSetUserNameAndPwd(Guid userId)
+ {
+ return ResponseOutput.Ok(await _userRepository.AnyAsync(t => t.Id == userId && t.EmailToken == _userInfo.UserToken));
+ }
[HttpGet]
public async Task InitSetUserNameAndPwd(Guid userId, string newUserName, string newPWd)
{
- await VerifyUserPwdAsync(userId, newPWd);
+ if (!await _userRepository.AnyAsync(t => t.Id == userId && t.EmailToken==_userInfo.UserToken))
+ {
+ return ResponseOutput.NotOk("您的初始化链接已过期");
+ }
+ await VerifyUserPwdAsync(userId, newPWd);
+
await VerifyUserNameAsync(userId, newUserName);
await _userRepository.UpdatePartialFromQueryAsync(userId, u => new User()
@@ -220,7 +233,9 @@ namespace IRaCIS.Application.Services
IsFirstAdd = false,
- }, true);
+ EmailToken = String.Empty
+
+ }, true) ;
return ResponseOutput.Ok();
}
diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs
index d6c9be6ef..493556c2b 100644
--- a/IRaCIS.Core.Domain/Management/User.cs
+++ b/IRaCIS.Core.Domain/Management/User.cs
@@ -69,6 +69,8 @@ namespace IRaCIS.Core.Domain.Models
public bool IsFirstAdd { get; set; } = true;
+ public string EmailToken { get; set; } = string.Empty;
+
[Projectable] public string FullName => LastName + " / " + FirstName;
//[Projectable] public string FullName => $"{LastName} / {FirstName}";