限制链接登陆一次

Uat_Study
hang 2022-05-30 09:43:01 +08:00
parent ae1137d2af
commit 458ca443fd
4 changed files with 39 additions and 4 deletions

View File

@ -2354,6 +2354,13 @@
<member name="M:IRaCIS.Application.Services.UserService.SendVerificationCode(System.String)">
<summary>发送验证码 修改邮箱(已经登陆修改) New </summary>
</member>
<member name="M:IRaCIS.Application.Services.UserService.VerifyCanInitSetUserNameAndPwd(System.Guid)">
<summary>
Result 为true 的时候 允许提交设置
</summary>
<param name="userId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Application.Services.UserService.ResetPassword(System.Guid)">
<summary>
重置密码为 默认密码

View File

@ -278,6 +278,8 @@ namespace IRaCIS.Application.Services
var token = _tokenService.GetToken(IRaCISClaims.Create(_mapper.Map<UserBasicInfo>(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<UserBasicInfo>(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<UserBasicInfo>(sysUserInfo)));
if (sysUserInfo.IsFirstAdd)
{
await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token });
}
var pathToFile = _hostEnvironment.WebRootPath
+ Path.DirectorySeparatorChar.ToString()

View File

@ -199,17 +199,30 @@ namespace IRaCIS.Application.Services
return ResponseOutput.Ok();
}
/// <summary>
/// Result 为true 的时候 允许提交设置
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IResponseOutput> VerifyCanInitSetUserNameAndPwd(Guid userId)
{
return ResponseOutput.Ok(await _userRepository.AnyAsync(t => t.Id == userId && t.EmailToken == _userInfo.UserToken));
}
[HttpGet]
public async Task<IResponseOutput> 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();
}

View File

@ -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}";