-
Notifications
You must be signed in to change notification settings - Fork 128
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
Add 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, |
Need this feature too, @paolosanchi have you managed to make it work ? |
I'm sorry, but I moved to https://github.com/stalniy/casl and I'm sticking with it. It has this feature and many more. |
#2 I'm submitting a...
Current behavior
Currently using the
ngxPermissionsOnly
andngxPermissionsExcept
we 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
The text was updated successfully, but these errors were encountered: