mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 18:52:05 +03:00
453833cd11
closes #5403 - adds gh-user-can helper to group user by minimum permissions - hide Nav settings menu for users below admin level
18 lines
666 B
JavaScript
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);
|