mirror of
https://github.com/YMFE/yapi.git
synced 2025-02-23 13:59:28 +08:00
fix: 增加的个人空间是public bug
This commit is contained in:
parent
fc2fa7b56b
commit
0dc6ef17ba
@ -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;
|
||||
|
@ -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'
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user