更新修改密码
This commit is contained in:
@@ -101,17 +101,33 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
}
|
}
|
||||||
// 邮箱和验证码都要被记住,然后注册时候比对邮箱和验证码是不是都和现在生成的一样
|
// 邮箱和验证码都要被记住,然后注册时候比对邮箱和验证码是不是都和现在生成的一样
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 修改密码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pwdDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
|
|
||||||
public async Task<Result> ChangePassword(ChangePwdDto pwdDto)
|
public async Task<Result> ChangePassword(ChangePwdDto pwdDto)
|
||||||
{
|
{
|
||||||
var user_data = await _userService.GetEntityById(pwdDto.id);
|
if (pwdDto.newPassword != null)
|
||||||
if (user_data.password == pwdDto.newPassword)
|
|
||||||
{
|
{
|
||||||
user_data.password = pwdDto.newPassword;
|
var user_data = await _userService.GetEntityById(pwdDto.id);
|
||||||
await _userService.UpdateAsync(user_data);
|
if (user_data.password == pwdDto.password)
|
||||||
return Result.Success();
|
{
|
||||||
|
user_data.password = pwdDto.newPassword;
|
||||||
|
user_data.phone = pwdDto.phone;
|
||||||
|
user_data.introduction = pwdDto.introduction;
|
||||||
|
user_data.email = pwdDto.email;
|
||||||
|
user_data.age = pwdDto.age;
|
||||||
|
user_data.address = pwdDto.address;
|
||||||
|
user_data.is_delete = pwdDto.is_delete;
|
||||||
|
user_data.nick = pwdDto.nick;
|
||||||
|
await _userService.UpdateAsync(user_data);
|
||||||
|
user_data.password = null;
|
||||||
|
return Result.Success().SetData(user_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.Error();
|
return Result.Error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ namespace Yi.Framework.Service
|
|||||||
{
|
{
|
||||||
var user_data=await _Db.Set<user>().Include(u=>u.roles)
|
var user_data=await _Db.Set<user>().Include(u=>u.roles)
|
||||||
.Where(u => u.id == user_id && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync();
|
.Where(u => u.id == user_id && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync();
|
||||||
|
user_data.roles.ToList().ForEach(u => u.users = null);
|
||||||
return user_data;
|
return user_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user