Meteor-Community-Packages/meteor-roles

Add isInRole to JS API as well

Ouverte

#56 ouverte le 19 sept. 2014

 (17 commentaires) (0 réaction) (0 personne assignée)JavaScript (161 forks)batch import
enhancementgood first issuehelp wanted

Métriques du dépôt

Stars
 (919 étoiles)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

Something you frequently do in the application, is check if the current user is allowed to access something. As there currently is no shorthand for this in the Javascript API, you have to do something like:

if ( Roles.userIsInRole( Meteor.userId(), 'permission' ) )
    // ...

I noticed the UI helper offers a beautiful shortand syntax for this, using the currently logged in user. I think it would make a lot of sense to add this to the API as well, so that one can simply do:

if ( Roles.isInRole( 'permission' ) )
    // ...

or even better:

if ( Roles.has( 'permission' ) )
    // ...

Guide contributeur