fix: 增加的个人空间是public bug

This commit is contained in:
suxiaoxin 2017-09-27 14:43:13 +08:00
parent fc2fa7b56b
commit 0dc6ef17ba
4 changed files with 11 additions and 18 deletions

View File

@ -134,6 +134,11 @@ class baseController {
if (type === 'group') {
let groupInst = yapi.getInst(groupModel);
let groupData = await groupInst.get(id);
if (groupData.uid === this.getUid()) {
return 'owner';
}
let groupMemberData = _.find(groupData.members, (m) => {
if (m.uid === this.getUid()) {
return true;

View File

@ -349,13 +349,7 @@ class groupController extends baseController {
group_name: 'User-' + this.getUid(),
add_time: yapi.commons.time(),
up_time: yapi.commons.time(),
type: 'private',
members: [{
uid: this.getUid(),
role: 'owner',
username: this.getUsername(),
email: this.getEmail()
}]
type: 'private'
})
}

View File

@ -144,7 +144,7 @@ class userController extends baseController {
type: 'third'
};
user = await userInst.save(data);
await this.handlePrivateGroup(user._id);
await this.handlePrivateGroup(user._id, username, email);
yapi.commons.sendMail({
to: email,
contents: `<h3>亲爱的用户:</h3><p>您好感谢使用YApi平台你的邮箱账号是${email}</p>`
@ -211,20 +211,14 @@ class userController extends baseController {
}
}
async handlePrivateGroup(uid){
async handlePrivateGroup(uid, username, email){
var groupInst = yapi.getInst(groupModel);
await groupInst.save({
uid: uid,
group_name: 'User-' + uid,
add_time: yapi.commons.time(),
up_time: yapi.commons.time(),
type: 'public',
members: [{
uid: uid,
role: 'owner',
username: this.getUsername(),
email: this.getEmail()
}]
type: 'private'
})
}
@ -298,7 +292,7 @@ class userController extends baseController {
let user = await userInst.save(data);
this.setLoginCookie(user._id, user.passsalt);
await handlePrivateGroup(user._id);
await this.handlePrivateGroup(user._id, user.username, user.email);
ctx.body = yapi.commons.resReturn({
uid: user._id,
email: user.email,

View File

@ -96,7 +96,7 @@ class groupModel extends baseModel {
list() {
return this.model.find({
type: 'public'
}).select('group_name _id group_desc add_time up_time type').exec();
}).select('group_name _id group_desc add_time up_time type uid').exec();
}
del(id) {