AlexKhymenko / ngx-permissions

Permission and roles based access control for your angular(angular 2,4,5,6,7,9+) applications(AOT, lazy modules compatible
MIT License
936 stars 126 forks source link

Create directive ngxPermissionsOnlyAll to validate that you have ALL the rules #153

Closed abalad closed 3 years ago

abalad commented 3 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ X ] Feature request
[ ] Documentation issue or request

Current behavior

I would like to specify multiple permissions that the user needs to have in order to complete an action. The issue is that he needs to have all permissions not just one of them, so the logic needs to be "and" not "or".

Expected behavior

<div *ngxPermissionsOnlyAll="['Read', 'Write']">
    <div>You can see this text </div>
</div>

Environment


Angular version: 10.0.0
ngx-permissions version: 8.0.0


Browser:
- [x ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX            
AlexKhymenko commented 3 years ago

@abalad Hi its possible with roles roles use and operator

 ngxRolesService
  .addRole('ADMIN', ['read', 'write']);

And then just use


<div *ngxPermissionsOnly="['ADMIN']">
    <div>You can see this text </div>
</div>

If the user doesnt have read and write it will not show.