mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Only group admins can see group edit page.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||
import Group from 'discourse/models/group';
|
||||
|
||||
var Tab = Em.Object.extend({
|
||||
@computed('name')
|
||||
@@ -53,18 +54,18 @@ export default Ember.Controller.extend({
|
||||
this.get('tabs')[0].set('count', this.get('model.user_count'));
|
||||
},
|
||||
|
||||
@computed('model.is_group_user', 'model.is_group_owner', 'model.automatic')
|
||||
getTabs(isGroupUser, isGroupOwner, automatic) {
|
||||
@computed('model.is_group_owner', 'model.automatic')
|
||||
getTabs(isGroupOwner, automatic) {
|
||||
return this.get('tabs').filter(t => {
|
||||
let display = true;
|
||||
let canSee = true;
|
||||
|
||||
if (this.currentUser && t.get('requiresGroupAdmin')) {
|
||||
display = automatic ? false : (this.currentUser.admin || isGroupOwner);
|
||||
} else if (t.get('requiresGroupAdmin')) {
|
||||
display = false;
|
||||
if (this.currentUser && t.requiresGroupAdmin) {
|
||||
canSee = this.currentUser.canManageGroup(this.get('model'));
|
||||
} else if (t.requiresGroupAdmin) {
|
||||
canSee = false;
|
||||
}
|
||||
|
||||
return display;
|
||||
return canSee;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,9 +17,10 @@ const Group = RestModel.extend({
|
||||
return Em.isEmpty(value) ? "" : value;
|
||||
},
|
||||
|
||||
type: function() {
|
||||
return this.get("automatic") ? "automatic" : "custom";
|
||||
}.property("automatic"),
|
||||
@computed('automatic')
|
||||
type(automatic) {
|
||||
return automatic ? "automatic" : "custom";
|
||||
},
|
||||
|
||||
@computed('user_count')
|
||||
userCountDisplay(userCount) {
|
||||
@@ -93,6 +94,7 @@ const Group = RestModel.extend({
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@computed('flair_bg_color')
|
||||
flairBackgroundHexColor() {
|
||||
return this.get('flair_bg_color') ? this.get('flair_bg_color').replace(new RegExp("[^0-9a-fA-F]", "g"), "") : null;
|
||||
@@ -224,7 +226,7 @@ Group.reopenClass({
|
||||
|
||||
mentionable(name) {
|
||||
return ajax(`/groups/${name}/mentionable`, { data: { name } });
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
export default Group;
|
||||
|
||||
@@ -500,8 +500,11 @@ const User = RestModel.extend({
|
||||
|
||||
return summary;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
canManageGroup(group) {
|
||||
return group.get('automatic') ? false : (this.get('admin') || group.get('is_group_owner'));
|
||||
}
|
||||
});
|
||||
|
||||
User.reopenClass(Singleton, {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import Group from 'discourse/models/group';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
titleToken() {
|
||||
return I18n.t('groups.edit.title');
|
||||
@@ -7,6 +9,12 @@ export default Ember.Route.extend({
|
||||
return this.modelFor('group');
|
||||
},
|
||||
|
||||
afterModel(group) {
|
||||
if (!this.currentUser || !this.currentUser.canManageGroup(group)) {
|
||||
this.transitionTo("group.members", group);
|
||||
}
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
this.controllerFor('group-edit').setProperties({ model });
|
||||
this.controllerFor("group").set("showing", 'edit');
|
||||
|
||||
Reference in New Issue
Block a user