Moving authorization to utils

This commit is contained in:
Matthew Dillon 2015-07-04 11:34:31 -07:00
parent 1c47941413
commit cdc825cc6a
7 changed files with 38 additions and 13 deletions

View file

@ -1,8 +1,9 @@
import Ember from 'ember';
import userCanAdd from '../../../utils/user-can-add';
export default Ember.Component.extend({
canAdd: function() {
let role = this.get('session.currentUser.role');
return (role === 'W') || (role === 'A');
}.property('session.currentUser.role')
let user_role = this.get('session.currentUser.role');
return userCanAdd(user_role);
}.property('session.currentUser.role').readOnly(),
});

View file

@ -1,15 +1,13 @@
import Ember from 'ember';
import userCanEdit from '../../../utils/user-can-edit';
export default Ember.Component.extend({
classNames: ['grid-1'],
isEditing: false,
canEdit: function() {
let role = this.get('session.currentUser.role');
let id = this.get('session.currentUser.id');
let author = this.get('species.createdBy');
return (role === 'W' && (+id === author)) || (role === 'A');
}.property('session.currentUser.role', 'session.currentUser.id', 'species.createdBy'),
return userCanEdit(this.get('session.currentUser'), this.get('species.createdBy'));
}.property('session.currentUser', 'species.createdBy').readOnly(),
actions: {
save: function() {

View file

@ -1,15 +1,13 @@
import Ember from 'ember';
import userCanEdit from '../../../utils/user-can-edit';
export default Ember.Component.extend({
classNames: ['grid-1'],
isEditing: false,
canEdit: function() {
let role = this.get('session.currentUser.role');
let id = this.get('session.currentUser.id');
let author = this.get('strain.createdBy');
return (role === 'W' && (+id === author)) || (role === 'A');
}.property('session.currentUser.role', 'session.currentUser.id', 'strain.createdBy'),
return userCanEdit(this.get('session.currentUser'), this.get('strain.createdBy'));
}.property('session.currentUser', 'strain.createdBy').readOnly(),
actions: {
save: function() {