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

Add flag to disable ngx-permissions in runtime #205

Closed migueltercero closed 1 year ago

migueltercero commented 1 year 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

We have a layout component that imports and use ngx-permissions. This layout component is used by multiple applications.

Some applications don´t require security. For theses applications, we have a flag to disable security. The problem is they can´t disable ngx-permissions because import module is in layout component.

Can be disable ngx-permission in runtime even if NgxPermissionsModule.forRoot() is imported?

Thanks.

Expected behavior

Have a flag or function to disable ngx-permission evnt if NgxPermissionsModule.forRoot() is imported

AlexKhymenko commented 1 year ago

@migueltercero Yes its possible just create stub with all permissions and load it in loadPermissions function.

migueltercero commented 1 year ago

Thank you for your quick response.

We understand that your solution is do something like this:

this.permissions.service.loadPermissions(['permission1', 'permission2'] ....)

Load all permissions. Is correct?

The problem is that this shared component don´t knows permissions of each application, only each application knows their permissions.

For example, if we can define a pattern like this.permissions.service.loadPermissions('*'), this can be applied to a shared component. Or if we can rewrite some funtion that always return true ...

Thank you.

AlexKhymenko commented 1 year ago

In this case You need to inject stub directive instead of real for example this one https://github.com/AlexKhymenko/ngx-permissions/blob/master/projects/ngx-permissions/src/lib/testing/permissions-allow.directive.stub.ts

migueltercero commented 1 year ago

Ok, we will test your solution.

You can close this issue.

Thank you!!!