Skip to content

Instantly share code, notes, and snippets.

@raix
Created February 24, 2015 15:56
Show Gist options
  • Save raix/efc01f737509710c75b1 to your computer and use it in GitHub Desktop.
Save raix/efc01f737509710c75b1 to your computer and use it in GitHub Desktop.
Roles
roleTypes = {
'admin': 'Administrator',
'user': 'Bruger',
'editor': 'Redaktør',
};
roleTypesList = [];
_.each(roleTypes, function(val, key) {
roleTypesList.push({
_id: key,
name: val
});
});
Roles = {
current: function() {
var user = Meteor.user();
return user && user.role || '';
},
is: function(/* arguments */) {
var role = this.current();
for (var i = 0; i < arguments.length; i++) {
if (role == arguments[i]) return true;
}
return false;
},
not: function(/* arguments */) {
return !this.is.apply(this, arguments);
},
};
UI.registerHelper('Roles', Roles);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment