Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow removing prefix from URL / remove dynamic params (middleware) #180

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

webpolis
Copy link

Now, if we have a route like /api/users, we can remove the api prefix by passing a negative number to the middleware method; so, I'd do middleware(-1) to remove first part of the URL, or -2 to remove first 2 pieces of the URL.

Also, as part of this PR, we're now able to pass an additional argument to middleware(...) method: this new argument named dynamicParams, will set a list of URL parameters (as defined via express router, for example) that will be excluded from the resource name when checking permissions.

ATM, we didn't have a way to define a route (like a view endpoint, whose path looks like /user/89324892384) having a predefined parameter which is dynamic (:id, in this case). So, if I do:

acl.middleware(-1, getUser, 'view', ['id'])

I'm stating that the ACL module must only check for view permission over the rest of the resource's name, excluding the :id part.

@webpolis webpolis changed the title Allow removing prefix from URL by using negative number (middleware) Allow removing prefix from URL / remove dynamic params (middleware) Mar 16, 2016
Merge OptimalBits/node_acl/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant