fix: 管理员修改密码不需要原密码

This commit is contained in:
suxiaoxin 2017-10-20 17:31:09 +08:00
parent d788f78848
commit 7850c54507
2 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,6 @@
## 1.1.2
### Features
* 接口运行增加了 query 和 body 的 enable 选项,可选择是否请求该字段
* Mock 支持了时间戳占位符 @timestamp
@ -12,6 +13,10 @@
* 修复了日志链接错误问题
* 修复了添加用户 loading 问题
* 修复了用户名编辑,前台未更新问题
* 修复了复制接口导致 GET 请求显示 request-body 问题
* 修复了接口集页面刷新后跳转到第一个接口集问题
* 修复了接口用例页面修改 header 参数值没有效果 bug
* 修复了接口集页面导入接口会导致 reqBody 清空 bug
## 1.1.1
### Features

View File

@ -207,16 +207,17 @@ class userController extends baseController {
return ctx.body = yapi.commons.resReturn(null, 400, '密码不能为空');
}
let user = await userInst.findById(params.uid);
if (this.getRole() !== 'admin' && params.uid != this.getUid()) {
return ctx.body = yapi.commons.resReturn(null, 402, '没有权限');
}
if (this.getRole() !== 'admin') {
if (this.getRole() !== 'admin' || user.role === 'admin') {
if (!params.old_password) {
return ctx.body = yapi.commons.resReturn(null, 400, '旧密码不能为空');
}
let user = await userInst.findById(params.uid);
if (yapi.commons.generatePassword(params.old_password, user.passsalt) !== user.password) {
return ctx.body = yapi.commons.resReturn(null, 402, '旧密码错误');
}