改进密码的处理方式

This commit is contained in:
yzp 2025-07-18 15:41:04 +08:00
parent 92438e9085
commit 3528c784cb

View File

@ -110,8 +110,10 @@ public class SysUserService : IDynamicApiController, ITransient
if (await query.AnyAsync(u => u.Account == input.Account)) throw Oops.Oh(ErrorCodeEnum.D1003);
if (!string.IsNullOrWhiteSpace(input.Phone) && await query.AnyAsync(u => u.Phone == input.Phone)) throw Oops.Oh(ErrorCodeEnum.D1032);
var password = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SysPassword);
var password = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SysPassword);
// 如果有传密码上来,就不使用默认密码
if (!string.IsNullOrWhiteSpace(input.Password))
password = input.Password;
var user = input.Adapt<SysUser>();
user.Password = CryptogramHelper.Encrypt(password);
var newUser = await _sysUserRep.AsInsertable(user).ExecuteReturnEntityAsync();