fix: 命令行导入成员信息为 undefined

This commit is contained in:
gaoxiaolin.gao 2018-08-02 12:09:40 +08:00
parent f1a30fa071
commit c6172ef0fe
3 changed files with 9 additions and 3 deletions

View File

@ -3,6 +3,10 @@
* json schema number和integer支持枚举
* 服务端测试增加下载功能
### Bug Fixed
* 命令行导入成员信息为 undefined
### v1.3.21
* 请求配置增加 context.utils.CryptoJS

View File

@ -192,7 +192,7 @@ class baseController {
return 'owner';
}
let memberData = _.find(projectData.members, m => {
if (m.uid === this.getUid()) {
if (m && m.uid === this.getUid()) {
return true;
}
});

View File

@ -216,12 +216,14 @@ class interfaceController extends baseController {
}
// 新建接口的人成为项目dev 如果不存在的话
// 命令行导入时无法获知导入接口人的信息其uid 为 999999
let uid = this.getUid();
if (this.getRole() !== 'admin') {
if (this.getRole() !== 'admin' && uid !== 999999) {
let userdata = await yapi.commons.getUserdata(uid, 'dev');
// 检查一下是否有这个人
let check = await this.projectModel.checkMemberRepeat(params.project_id, uid);
if (check === 0) {
if (check === 0 && userdata) {
await this.projectModel.addMember(params.project_id, [userdata]);
}
}