fix 用户信息修改及密码修改的框架bug
This commit is contained in:
@@ -118,19 +118,31 @@ namespace Ewide.Core.Service
|
||||
|
||||
}
|
||||
|
||||
public class ChangePasswordUserInput : UpdateUserInput
|
||||
public class ChangePasswordUserInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户Id
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "用户Id不能为空")]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "旧密码不能为空")]
|
||||
public override string Password { get; set; }
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 新密码
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "新密码不能为空"), Compare(nameof(Password), ErrorMessage = "新旧密码不能一致")]
|
||||
[Required(ErrorMessage = "新密码不能为空")]
|
||||
[StringLength(32, MinimumLength = 5, ErrorMessage = "密码需要大于5个字符")]
|
||||
public string NewPassword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 确认密码
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "确认密码不能为空"), Compare(nameof(NewPassword), ErrorMessage = "两次密码不一致")]
|
||||
public string Confirm { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +233,12 @@ namespace Ewide.Core.Service
|
||||
public async Task UpdateUserInfo(UpdateUserInput input)
|
||||
{
|
||||
var user = input.Adapt<SysUser>();
|
||||
await user.UpdateAsync();
|
||||
await user.UpdateExcludeAsync(new string[] {
|
||||
nameof(SysUser.Account),
|
||||
nameof(SysUser.Password),
|
||||
nameof(SysUser.AdminType),
|
||||
nameof(SysUser.Status)
|
||||
}, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -247,6 +252,8 @@ namespace Ewide.Core.Service
|
||||
var user = await _sysUserRep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
||||
if (MD5Encryption.Encrypt(input.Password) != user.Password)
|
||||
throw Oops.Oh(ErrorCode.D1004);
|
||||
if (MD5Encryption.Encrypt(input.NewPassword).Equals(user.Password))
|
||||
throw Oops.Oh(ErrorCode.D10041);
|
||||
user.Password = MD5Encryption.Encrypt(input.NewPassword);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user