限制链接登陆一次

This commit is contained in:
2022-05-30 09:43:01 +08:00
parent ae1137d2af
commit 458ca443fd
4 changed files with 39 additions and 4 deletions
@@ -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();
}