Ghost/core/client/app/helpers/gh-user-can.js
cobbspur 453833cd11 Hide Nav Settings based on permissions
closes #5403

- adds gh-user-can helper to group user by minimum permissions
- hide Nav settings menu for users below admin level
2015-06-17 19:20:57 +01:00

18 lines
666 B
JavaScript

import Ember from 'ember';
// Handlebars Helper {{gh-user-can}}
// Usage: call helper as with first parameter of session.user and second parameter the minimum role
// e.g - {{#if (gh-user-can session.user 'admin')}} 'block content' {{/if}}
// @param1 session.user
// @param2 'admin' or 'editor'
export function ghUserCan(params) {
if (params[1] === 'admin') {
return !!(params[0].get('isOwner') || params[0].get('isAdmin'));
} else if (params[1] === 'editor') {
return !!(params[0].get('isOwner') || params[0].get('isAdmin') || params[0].get('isEditor'));
}
return false;
}
export default Ember.HTMLBars.makeBoundHelper(ghUserCan);