From 458ca443fdb79dd3fcd8adcbcd8135f8a7a08f22 Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Mon, 30 May 2022 09:43:01 +0800
Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E9=93=BE=E6=8E=A5=E7=99=BB?=
=?UTF-8?q?=E9=99=86=E4=B8=80=E6=AC=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../IRaCIS.Core.Application.xml | 7 ++++++
.../Service/Common/MailService.cs | 11 +++++++++
.../Service/Management/UserService.cs | 23 +++++++++++++++----
IRaCIS.Core.Domain/Management/User.cs | 2 ++
4 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index b4e7d958..e14ac298 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 0f021e33..2d4fbbba 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 45b54d71..b6e7630a 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 d6c9be6e..493556c2 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}";