FIX: Don't show logs if user is not an admin or group owner.

This commit is contained in:
Guo Xiang Tan 2016-12-12 20:30:00 +08:00
parent 5db6306218
commit 405ffbf5a4
1 changed files with 13 additions and 4 deletions

View File

@ -21,7 +21,10 @@ export default Ember.Controller.extend({
Tab.create({ name: 'topics' }),
Tab.create({ name: 'mentions' }),
Tab.create({ name: 'messages', requiresMembership: true }),
Tab.create({ name: 'logs', i18nKey: 'logs.title', icon: 'shield', requiresMembership: true })
Tab.create({
name: 'logs', i18nKey: 'logs.title', icon: 'shield',
requiresMembership: true, requiresGroupAdmin: true
})
],
@computed('model.is_group_owner', 'model.automatic')
@ -58,13 +61,19 @@ export default Ember.Controller.extend({
});
},
@computed('model.is_group_user')
getTabs(isGroupUser) {
@computed('model.is_group_user', 'model.is_group_owner')
getTabs(isGroupUser, isGroupOwner) {
return this.get('tabs').filter(t => {
let isMember = false;
if (this.currentUser) {
isMember = this.currentUser.admin || isGroupUser;
let admin = this.currentUser.admin;
if (t.get('requiresGroupAdmin')) {
isMember = admin || isGroupOwner;
} else {
isMember = admin || isGroupUser;
}
}
return isMember || !t.get('requiresMembership');