Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd optional context to directives #145
Comments
|
I need this too, if anyone is already on it, I'm going with the implementation. however, probably the best for routing is doing like this:
|
|
As I expected the issue is that the validation function is defined as this:
it means that if we set the context as the first parameter it would break every compatibility, unless we do something like this:
and the validation caller would pass the context instead of the name when specified, but this behaviour could result confusing. the easiest way would be obviously this:
Any other ideas? |
|
I made the changes to do this, and it was almost easy, you can check it out here (I'll provide some examples soon): The router part is not completed yet, but I'm almost there. I've an issue with the build, @AlexKhymenko what is the command to run? When I import the dist folder to my test project I got errors, |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

#2 I'm submitting a...
Current behavior
Currently using the
ngxPermissionsOnlyandngxPermissionsExceptwe can pass one or more permission or role names as string and basically it checks whether the current user has that/one of them or not. The permission/role itself can provide a validator function which is able to perform simple validations like in the roles example checking the session state.Expected behavior
What in many cases would be helpful is to validate permissions or roles with a given context. For example within a list of objects where each object has actions like view/edit/delete we not only need to check if user X can view/edit/delete objects of that type but for example if he can view/edit/delete that specific object.In my actual use case the action is editing permissions of contacts. But the contact can either be a "simple" data item or connected with an user account which can login or not. So user X editing (assigning) permissions to contact A only makes sense if user X has the permission "edit contact permissions¨ and contact A is able to login.
This could be solved by providing an optional context to the validator function via the directives, pipes and maybe also the routes (the question is how to define what to pass from routing).
Directives:
Pipes:
(example from #124 adapted)
Permission/role validator function:
Environment