0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Added user.isOwnerOrAdmin CP

This commit is contained in:
Kevin Ansfield 2019-01-22 16:22:12 +00:00
parent 0afe467a52
commit 33450a4ee1
3 changed files with 4 additions and 3 deletions

View file

@ -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) {

View file

@ -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 () {

View file

@ -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');
}
});