Commit 04537360 by 王昆

gsb

parent ebc94188
......@@ -55,6 +55,9 @@ class ActionAPI extends APIBase {
case "userEnabled":
opResult = await this.userSve.enabled(action_body);
break;
case "userResetPassword":
opResult = await this.userSve.userResetPassword(action_body);
break;
case "userMapByIds":
opResult = await this.userSve.mapByIds(action_body);
break;
......
......@@ -64,6 +64,29 @@ class UserService extends ServiceBase {
return await this.saveUser(obj);
}
async userResetPassword(params) {
let id = params.id;
let oldPassword = await this.getEncryptStr(this.trim(params.oldPassword));
let newPassword = this.trim(params.newPassword);
let newPasswordConfirm = this.trim(params.newPasswordConfirm);
let user = await this.findById(id);
if (!user) {
return system.getResult(null, "修改密码失败,用户不存在");
}
if (!newPassword) {
return system.getResult(null, "修改密码失败,新密码不能为空");
}
if (newPassword != newPasswordConfirm) {
return system.getResult(null, "修改密码失败,两次密码输入不一致");
}
if (user.password != oldPassword) {
return system.getResult(null, "修改密码失败,原密码错误");
}
user.password = await this.getEncryptStr(newPassword);
await user.save();
return system.getResultSuccess();
}
async saveUser(obj) {
let id = obj.id;
let password = this.trim(obj.password);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment