修改密码时,顺便修改用户名,另外Site调研增加查询条件
This commit is contained in:
@@ -167,6 +167,8 @@ namespace IRaCIS.Application.Contracts
|
||||
|
||||
public class EditPasswordCommand
|
||||
{
|
||||
public string NewUserName { get; set; } = string.Empty;
|
||||
|
||||
public string NewPassWord { get; set; } = string.Empty;
|
||||
public string OldPassWord { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace IRaCIS.Application.Services
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发送验证码 邮箱或者手机号
|
||||
@@ -255,6 +255,7 @@ namespace IRaCIS.Application.Services
|
||||
/// <param name="resetPwdModel"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
|
||||
public async Task<IResponseOutput> SetNewPassword(ResetPasswordCommand resetPwdModel)
|
||||
{
|
||||
if (resetPwdModel.IsReviewer)
|
||||
@@ -520,6 +521,23 @@ namespace IRaCIS.Application.Services
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> ModifyPassword(EditPasswordCommand editPwModel)
|
||||
{
|
||||
|
||||
|
||||
if( !string.IsNullOrEmpty(editPwModel.NewUserName))
|
||||
{
|
||||
if (await _userRepository.AnyAsync(t => t.UserName == editPwModel.NewUserName && t.Id != _userInfo.Id))
|
||||
{
|
||||
return ResponseOutput.NotOk("UserId already exists");
|
||||
}
|
||||
|
||||
var success = await _userRepository.UpdateFromQueryAsync(t => t.Id == _userInfo.Id, u => new User()
|
||||
{
|
||||
UserName = editPwModel.NewUserName,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//验证旧密码OK
|
||||
if (await _userRepository.FirstOrDefaultAsync(t => t.Id == _userInfo.Id && t.Password == editPwModel.OldPassWord) != null)
|
||||
{
|
||||
var success = await _userRepository.UpdateFromQueryAsync(t => t.Id == _userInfo.Id, u => new User()
|
||||
@@ -531,10 +549,12 @@ namespace IRaCIS.Application.Services
|
||||
return ResponseOutput.Result(success);
|
||||
}
|
||||
|
||||
//医生密码
|
||||
if (await _doctorRepository.AnyAsync(t => t.Id == _userInfo.Id && t.Password == editPwModel.OldPassWord))
|
||||
{
|
||||
var success = await _doctorRepository.UpdateFromQueryAsync(t => t.Id == _userInfo.Id, u => new Doctor()
|
||||
{
|
||||
|
||||
Password = editPwModel.NewPassWord
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user