reactioncommerce/meteor-security

how to use dynamic role with security?

Closed this issue · 1 comments

For example I have 2 user like:

// user 1
username: 'test1'
user.roles = ['post.insert']

// user 2
username: 'test2'
user.roles = ['post.insert', 'post.update']

So I need to pass dynamic variable to role on security via user log in.

// Check user role
var role = .........
Posts.permit('remove').ifHasRole({role: role}).apply();

How to solve?

The built-in ifHasRole is for simple checks. You will have to write your own rule method with the checks you need. You can copy the built-in one and change its name and change it to do what you need.