Skip to content

Commit

Permalink
Added user.isOwnerOrAdmin CP
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinansfield committed Jan 22, 2019
1 parent 126be42 commit 0923b1d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/helpers/gh-user-can-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {helper} from '@ember/component/helper';
// @param session.user

export function ghUserCanAdmin(params) {
return !!(params[0].get('isOwner') || params[0].get('isAdmin'));
return !!(params[0].isOwnerOrAdmin);
}

export default helper(function (params) {
Expand Down
3 changes: 2 additions & 1 deletion app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export default Model.extend(ValidationEngine, {
isAdmin: equal('role.name', 'Administrator'),
isOwner: equal('role.name', 'Owner'),

// This is used in enough places that it's useful to throw it here
// These are used in enough places that it's useful to throw them here
isOwnerOrAdmin: or('isOwner', 'isAdmin'),
isAuthorOrContributor: or('isAuthor', 'isContributor'),

isLoggedIn: computed('id', 'session.user.id', function () {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/subscribers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default AuthenticatedRoute.extend({
return RSVP.hash(promises).then((hash) => {
let {user, subscribers} = hash;

if (!subscribers || !(user.get('isOwner') || user.get('isAdmin'))) {
if (!subscribers || !user.isOwnerOrAdmin) {
return this.transitionTo('posts');
}
});
Expand Down

0 comments on commit 0923b1d

Please sign in to comment.