alexkhymenko / ngx-permissions Goto Github PK
View Code? Open in Web Editor NEWPermission and roles based access control for your angular(angular 2,4,5,6,7,9+) applications(AOT, lazy modules compatible
License: MIT License
Permission and roles based access control for your angular(angular 2,4,5,6,7,9+) applications(AOT, lazy modules compatible
License: MIT License
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ x] Feature request
[ ] Documentation issue or request
No test support.
It would be nice with mock module or the likes, so that:
Angular version: 5.2.1
ngx-permissions version: 3.1.0
Browser:
All
``
Hi Alex,
I am happy to use your library in project!
Could you help me please with one question?
<myComponent *ngxPermissionsOnly="'ADMIN'; authorisedStrategy: disabledFunc; unauthorisedStrategy: enableFunc">
</myComponent>
public disabledFunc(templateRef: TemplateRef<any>) {
// I want the button in the component to disable. What should I do?
}
@Component({
selector: 'myComponent',
template: `
<h2>{{title}}</h2>
<button> <div>123</div></button>
`}
I want the button in the component to disable. What should I do?
<p ngxPermissionsOnly="GUEST">Members online</p>
NgxPermissionsService.loadPermissions(["A"]); NgxRolesService.addRole('ADMIN', ['A'] );
let roles = NgxRolesService.getRoles();
NgxRolesService.roles$.subscribe((data) => { console.log(data); })
{ "ADMIN": { "name": "ADMIN", "validationFunction": [ "A" ] } }
<p ngxPermissionsOnly="'GUEST'">Members online</p>
<p ngxPermissionsOnly="'[GUEST']">Members online</p>
but still GUEST permission's p tag is visible or even directive not readable in template.
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
ngxpermissionsOnly
shows an element on the first page load, but that item is hidden when the page is refreshed or when you navigate away from a page and then back again.
ngxPermissionsOnly
should show and hide elements consistently regardless of page refresh and navigation
addPermission
or loadPermissions
ngxPermissionsOnly
directive in a view to show or hide an elementngxPermissionsOnly
--> Element is shown since user has correct permissionsCode:
auth.service.ts:
export class AuthService {
constructor(private ngxPermissionsService: NgxPermissionsService) {
//...
}
//Function called after a user logs in
public afterSignIn() {
const permissionNames = ["create-contract", "create-payment", "create-prospect", "modify-contract", "modify-invoiced", "modify-prospect", "modify-quickbooks-reference-id", "modify-sales-actions"];
// Always return true for testing purposes
this.ngxPermissionsService.addPermission(allFrontendPermissionNames, (permissionName, permissionStore) => {
return true;
});
//redirect to home component
}
}
home.component.ts
<ng-template [ngxPermissionsExcept]="['modify-sales-actions', 'create-contract']">
<div class='row'>
<div class='col-sm-12'>
<h1> Perms Test </h1>
</div>
</div>
</ng-template>
Angular version: 4.0.0
ngx-permissions version: 3.0.0
Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [x] Firefox version XX
- [x] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
[X] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
Version 3.2.0 is not including new NgxPermissionsAllowStubDirective, NgxPermissionsRestrictStubDirective with the NgxPermissionsModule.
I am sure you just forgot to add this?
Browser:
- [X] Chrome (desktop) version XX
- [X] Chrome (Android) version XX
- [X] Chrome (iOS) version XX
- [X] Firefox version XX
- [X] Safari (desktop) version XX
- [X] Safari (iOS) version XX
- [X] IE version XX
- [X ] Edge version XX
I am loading the permissions in AppComponent as per the documentation and I am boot strapping the same component in app.module.ts.
When I am trying to get permissions in any other component then this returns empty object.
I have also added the NgxPermissionsService in providers array in app.module.ts
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
Hi,Thank you all for your great job, I'm using this library for a web application that support multiple roles each role has different permissions my problem is that the permissions that i load doesn't persist in the browser a soon as i refresh the page the getPermissions function return an empty object
PS: I'm using ngx-permissions 4.0.0 instead of 5.0.0 because i get this error rxjs.merge is not a function
The permissions should persist even when we change the navigation
Angular version: 5.1.0
ngx-permissions version: 4.0.0
Browser:
- [ ] 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
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
When following the examples from the setup guide, we are simply including NgxPermissionsModule.forRoot() in our imports inside our app.module.ts, we then have a nav menu component which we are trying to use the directives on to show and hide anchor links. We are receiving the error:
"Property binding ngxPermissionsOnly not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations"
and
"Can't bind to 'ngxPermissionsOnly' since it isn't a known property of 'a'"
Is there a step we have missed in importing/including this in our project?
Desired result is that the directive works without errors
Follow steps above in current behavior.
Angular version: 6.0.0
ngx-permissions version: 5.0.0? (whichever is newest in npm)
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
Do you have any plans on migrating this repo to use the new Angular CLI library configuration?
https://github.com/angular/angular-cli/wiki/stories-create-library
Are you accepting PRs?
Thanks!
I'm submitting a Bug report
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Router } from '@angular/router'; ... import { NgxPermissionsService } from 'ngx-permissions'; @Component({ selector: 'app-bandeau-qoq', templateUrl: './bandeau-qoq.component.html', styleUrls: ['./bandeau-qoq.component.less'] }) export class BandeauQoqComponent implements OnInit { public isCollapsed = false; // Indique si le bandeau doit être réduit. // Enumération 'états des dossiers' private etatEnum = EtatEnum; private dossierService: DossierService; // Rendre le service accessible dans la vue private quoi: TypeSignalement; private ou: Regate; private quand: QuandForm; // Detecter la valeur précédente de la version de dossier // Nous aide dans la gestion du cache des données globales @Input() isEditMode: boolean; @Input() dossier: Dossier; @Output() changeSection: EventEmitter = new EventEmitter(); @Output() validationGlobale: EventEmitter = new EventEmitter(); constructor(private dossierServiceInj: DossierService, private router: Router, private app: AppComponent, private permissionsService: NgxPermissionsService) { this.dossierService = dossierServiceInj; } ngOnInit() { console.log("permission :"); const perm = ["ADMIN", "EDITOR"]; this.permissionsService.loadPermissions(perm); console.log(this.permissionsService.getPermissions());
it's works fine : i can get the permissions in the console
<ng-container *ngxPermissionsOnly="['ADMIN']">
When i use a directive in the template, the following error appears in the console (chrome)
Error: Uncaught (in promise): TypeError: rxjs_Observable.Observable.merge(...).mergeAll is not a function TypeError: rxjs_Observable.Observable.merge(...).mergeAll is not a function at NgxPermissionsService.hasArrayPermission (ngx-permissions.umd.js:189)
Angular version: 4.0.0
ngx-permissions version: 2.1.0
Browser: Chrome (desktop) version 61.0.3163.100 (Build officiel) (32 bits)
Hi,
it seems, the directives (eg. ngxPermissionsOnly) cannot be used within an "*ngFor" loop.
Example:
...*ngFor="let child of children" ..
In the example above, {{child.value}} does not get rendered - it seems to be shadowed by your Directive.
Can you confirm?
Is it by intent?
Thx a lot,
raven
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
I'm trying to capture the permissionsAuthorized event that is thrown when the permission is granted, but the method that I have linked to the event is not executed.
I need to listen when permission is granted.
Template side:
<li *ngxPermissionsOnly="'canAccessSettings'" (permissionsAuthorized)="reloadMenu()">Item<li>
Component side:
public reloadMenu($event): void { console.log('reloadMenu', $event); }
Angular version: 5.2.5
ngx-permissions version: 4.1.0
Browser:
- [X] Chrome (desktop) version 64.0.3282.186
- [ ] 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
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
Validation passes if permission is common for different roles
Need to have strict permission set validation.
ROLE_A: ['perm_a', 'perm_b']
ROLE_B: ['perm_a]
Need to show element only to ROLE_A and completely hide to ROLE_B.
Angular version: 5.1.0
ngx-permissions version: 4.1.0
Browser:
- [ ] 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
I do not know if I forgot something, but by forcing the reload of the page, I lose the permissions in memory.
The solution to my problem was to get the permissions saved in the localStorage and after the reload call the loadPermissions([permissions]) method ;
Would that be the best approach?
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ X] Bug report
[ ] Feature request
[ ] Documentation issue or request
Does not work with rxjs 6.0
Angular version: X.Y.Z
ngx-permissions version: X.Y.Z
Browser:
- [ ] 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
Hai Alex,
I am using your library is there any possibility for user role Based Button disabled.
Please advice . Using permissionsAuthorized and permissionsAuthorized
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
First thank you for this! It was just what we were looking for. We have functionality where a user can impersonate another role. I’m wondering how I’d go about checking to see if if the user has permission to the current route?
Angular version: X.Y.Z
ngx-permissions version: X.Y.Z
Browser:
- [ ] 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
[X ] Feature request
Not currently possible
Angular CLI: 1.7.4
Node: 9.11.1
OS: darwin x64
Angular: 5.2.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker
@angular/cli: 1.7.4
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.6.2
webpack: 3.11.0
ngx-permissions version: 4.1.0
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
If i compile project with aot (--prod) flag. I got error in browser console Observable.merge is not a function
in validateExceptOnlyPermissions
Angular version: 5.2.0
ngx-permissions version: 3.2.3
Browser:
- [ ] 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
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
<ng-template [ngxPermissionsOnly]="['ROLE_ADMIN','ROLE_USER']">
<div>ROLE_ADMIN | ROLE_USER</div>
</ng-template>
View directive is OR-ed (ROLE_USER || ROLE_ADMIN)
{ path: 'quick-quote', component: QuickQuoteStartComponent,
canActivate: [NgxPermissionsGuard],
data: { permissions: { only: ['ROLE_USER','ROLE_ADMIN'], redirectTo: loginRedirect} }
},
Route guard is AND-ed (ROLE_USER && ROLE_ADMIN)..
They should work the same
Angular version: @angular/cli: 1.4.6
ngx-permissions version: 2.1.1
Hi, i extend my congratulations for this component. But when i have a user with role admin and role editor and want to access a functionality with role admin the user cant not access because it have a role with lower permission. thanks again
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
Are you going to provide a service to implement the canLoad function when importing a module with lazy loading? It would be a great help!
Hi, Alex! We are happy to use your library in our project!
Could you help me please with one question?
I need to disable the button when the user hasn't required permissions and now the only possibility to achieve this, as I understood, is to clone template of the button, make it disabled and pass it to elseBlock
.
Is it possible to avoid such of code cloning and provide kind of predefined Strategies of actions to elements with which user has no rights to interact?
Thank you for your attention!
update angular 4.2 to 5.2.8 and update ngx-permisison package but not working a
Got error
rxjs.merge is not a function
at NgxPermissionsDirective.validateExceptOnlyPermissions (ngx-permissions.umd.js:632)
at NgxPermissionsDirective.ngOnInit (ngx-permissions.umd.js:611)
at checkAndUpdateDirectiveInline (core.js:12411)
at checkAndUpdateNodeInline (core.js:13935)
at checkAndUpdateNode (core.js:13878)
at debugCheckAndUpdateNode (core.js:14771)
at debugCheckDirectivesFn (core.js:14712)
at Object.eval [as updateDirectives] (AppSidenavComponent.html:22)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:14697)
at checkAndUpdateView (core.js:13844)
it should be work fine with angular 5.2.8
Angular version: 5.2.8
ngx-permissions version: X.Y.Z
rxjs: 5.5.6
Browser:
- [ ] Chrome (desktop) version XX
Hello guys!
I have kind of problem, when I can't access to component class fields from my ng-template
's.
Could you help me, how could i solve this problem?
Here is code example
<ng-template [ngxPermissionsOnly]="'PERMISSION'"
[ngxPermissionsOnlyThen]="allowAccess"
[ngxPermissionsOnlyElse]="denyAccess">
</ng-template>`
<ng-template #allowAccess>
<button type="submit" class="btn btn-primary">{{ componentVar }}</button>
</ng-template>
<ng-template #denyAccess>
<button disabled type="submit" class="btn btn-primary">{{ componentVar }}</button>
</ng-template>
And text where should be componentVar is empty
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
Neither the directives ngxPermissionsOnly
, ngxPermissionsExcept
, nor except
and only
with routes work when using roles. Neither the plunker demo is working with roles.
When user adds roles using their service, from the documentation it seems, they should be appliable as well as permissions added using their service.
Go to roles page
https://plnkr.co/edit/n6Wa6hXg0JzI6e050wBt?p=preview
Angular version: v5.2.1
ngx-permissions version: X.Y.Z
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
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
It's not an issue, just a question : I would like to know how can I redirect on page with the redirectTo command into a routing.
{
path: 'test/:id',
component: testComponent,
canActivate: [NgxPermissionsGuard],
data: {
permissions: {
only: ["ROLE_USER"],
redirectTo: ['/login'] // would like to redirect to /login?not_authorized=1
}
}
},
Angular version: 5.3.2
ngx-permissions version: 4.1.0
Browser:
- [ ] 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
We have 3 child route and 1 root route
I used to build angular 4 application with nodejs we have 2 admin panel, 1 site and app.module.ts we used for lazy loading, ngx-permissions, NgxPermissionsGuard.
After the user login from oneadmin they can access every route but if user is in dashboard user can't able to refresh page, if user refresh page it's redirect to http://127.0.0.1:3000.
http://127.0.0.1:3000/oneadmin/dashboard
http://127.0.0.1:3000/oneadmin/profile
here is route code
const oneadminroutes: Routes = [
{
path: 'oneadmin', pathMatch: 'full', redirectTo: 'oneadmin/login',
},
{
path: 'oneadmin/login', component: LoginComponent,
},
{
path: 'oneadmin',
component: OneAdminComponent,
pathMatch: 'prefix',
children: [
{
path: 'dashboard',
component: DashboardComponent,
pathMatch: 'prefix',
canActivate: [NgxPermissionsGuard],
data: {
permissions: { only: ['role1', 'role2', 'role3'] }
}
},
{
path: 'profile',
component: UserProfileComponent,
canActivate: [NgxPermissionsGuard],
data: {
permissions: { only: ['role1', 'role2', 'role3'] }
}
},
]
}
];
export const OneadminRoutingModule: ModuleWithProviders = RouterModule.forChild(oneadminroutes);
if user refresh the page it want redirect to to anywhere just stay them in to current page.
http://127.0.0.1:3000/oneadmin/dashboard
Angular version :
Angular CLI: 1.6.1
Node: 8.9.1
OS: linux ia32
Angular: 5.1.1
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router
@angular/cli: 1.6.1
@angular/language-service: 4.4.6
@angular/tsc-wrapped: 4.4.6
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.1
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.6.2
webpack: 3.10.0
ngx-permissions version: ^3.0.0
Browser:
- [ ] Chromium (Ubuntu desktop) : version Version 62.0.3202.89 (Official Build) Built on Ubuntu , running on Ubuntu 16.04 (32-bit)
- [ ] Firefox version (Ubuntu desktop) : 57.0.1 (32-bit)
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
Angular version: X.Y.Z
ngx-permissions version: X.Y.Z
Browser:
- [ ] 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
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
I'm not sure if I understood well but how can I use my permissions into the view ? I've got this permission : "canEdit" and I would like to do something like that and I don't know if it's possible :
<ng-template [ngxPermissionsOnly]="['ROLE_USER']" OR "canEdit"> <button fxHide.xs="true" fxShow.gt-sm="true" mat-raised-button color="primary" (click)="redirect('items/add')"><i class="material-icons">add</i>Add item</button> </ng-template>
Is it possible to use the permission and not the role ?
Thank you :)
Angular version: X.Y.Z
ngx-permissions version: X.Y.Z
Browser:
- [ ] 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
I have the following issue i save my jwt token in the local storage now on page refresh i am retrieving the users permissions and roles from an api but it seems the guard is firing before the permissions and roles have been loaded. so my question is how can i wait for the roles and permissions to be resolved before firing the NgxPermissionsGuard
Hai ,
I am using ngx permissions library . i create role base navigation menu but meanwhile
not able to work role based permmisons button view update is there possibility meand please explain
let routes = [
{ path: '',
canActivate: [AuthGuard],
children: [
{path: 'component',
component: ComponentName,
canActivate: [NgxPermissionsGuard],
data: {
permissions: {
only: ['ADMIN', 'MODERATOR'],
redirectTo: 'another-route'
}
}}
]
}
]
Here you've hardcoded the permissions only for the routes right? But I want to take the details from the database. Is there any way to load that?
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[x] Feature request
[x] Documentation issue or request
it looks to me that
<div *ngxPermissionsOnly="['ADMIN', 'GUEST']">
<div>You can see this text congrats</div>
</div>
works like or
and will show if ADMIN or if GUEST.
I'm looking for and
use case, is it possible with current version?
I imagine it might be like
<div *ngxPermissionsAnd="['canDoAction1', 'canDoAction2']">
Congrats you can do both actions:
<div>item 1 <button>action1</button></div>
<div>item 2 <button>action2</button></div>
</div>
so the area will appear only if user has permission to do both actions
I have an implementation question.
I have app, where auth.service is loading permissions (roles) after authentication.
After I call loadPermissions in every component or module, i need to check auth.
But I have feeling, that this is not correct way. You load in your example app (hardcoded) permission in app.component and I am wondering, where is correct place to load permissions, after authentication, without needed to load them every time (in every component etc) i need to check perm.
Can you please give me an advise ?
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[ x ] Documentation issue or request
Normally it is working fine but in the unit test i am not able to bypass the directive condition. How can i bypass it
<ng-container *ngxPermissionsOnly="['SUBSCRIPTION_OWNER','USER_MANAGER']">
<i *ngIf="!userRole?.isLastOwner" class="fa fa-user-times grid-icon" >
now in unit test case i have provided the
permissionservice.Loadpermission("permissions here")
But still i am not able to get the I tag
Angular version: 5
ngx-permissions version: X.Y.Z
Browser:
- [ x] Chrome (desktop) version XX
- [ x] Chrome (Android) version XX
- [ x] Chrome (iOS) version XX
- [ x] Firefox version XX
- [ x] Safari (desktop) version XX
- [ x] Safari (iOS) version XX
- [ x] IE version XX
- [ x] Edge version XX
Hello, everyone!
I would like to know could I override the NgxGuardPermissions? I just want to make logout if permission is denied.
Thanks!
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
In the Multiple Permissions section of the docs it states that loadPermissions
"will remove older permissions and pass only new"
loadPermissions
should remove older permissions and replace with the new
this.ngxPermissionsService.loadPermissions(['admin', 'test']);
this.ngxPermissionsService.loadPermissions(['another', 'random']);
// 'admin' and 'test' permissions still exist
Hi,
When using the ngxPermission directives inside compoent that uses OnPush strategy
the elements are not rendered correctly, if i invoke the changeDetectorRef.detectchanges manully
than everything is fine.
The strange issue is that if i have nested levels of permission directives inside the same component
i need to invoke the changeDetectorRef.detectchanges for each nesting level.
Can you please advise how to solve this ?
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[X] Documentation issue or request
How to implement the ownership-based access control, allowing for example only the owner to edit
a specific resource?
I would allow to edit a resource
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[x] Feature request
[x] Documentation issue or request
it's possible to build hierarchical rules?
you can:
<div *ngxPermissionsOnly="['CREATE']">
<span class="btn">create new</span>
</div>
<div *ngxPermissionsOnly="['READ']">
<span class="btn">view</span>
</div>
<div *ngxPermissionsOnly="['UPDATE']">
<span class="btn">edit</span>
</div>
<div *ngxPermissionsOnly="['DELETE']">
<span class="btn">delete</span>
</div>
which should:
show all 4 buttons in case you have DELETE role/permission - CRUD
show 3 buttons in case you have UPDATE role/permission CRU
show 2 buttons in case you have Create/Read role/permission CR
show 1 button in case you have Read role/permission R
this.persmissionService.addPermission('READ');
this.rolesService.addRole('CREATE', ['READ'])
this.rolesService.addRole('UPDATE', ['CREATE'])
this.rolesService.addRole('DELETE', ['UPDATE'])
in other words considering this hierarchy delete > update > create > read
will the div below show up if user has "DELETE" permission?
<div *ngxPermissionsOnly="['READ']">
<span class="btn">view</span>
</div>
or it can be achieved by repeating
this.rolesService.addRole('DELETE', ['CREATE', 'READ', 'UPDATE'])
this.rolesService.addRole('UPDATE', ['CREATE', 'READ'])
this.rolesService.addRole('CREATE', ['READ'])
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
When I use lib to restrict access to a component, this component will be loaded twice if access is granted
The component should be loaded only once.
<div *ngxPermissionsOnly="['DEFINE_REPORTING']">
<hsmt-reporting [siteId]="siteId"></hsmt-reporting>
</div>
With this code I can see that the hsmt-reporting component constructor is run twice if access is granted.
Angular version: 4.0.3
ngx-permissions version: 2.1.1
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
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
v5.0.0-rc.0 does not work with rxjs6
Angular version: X.Y.Z
ngx-permissions version: X.Y.Z
Browser:
- [ ] 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
Hi!
I have this error after update angular version
TypeError: rxjs_Observable.Observable.merge(...).mergeAll(...).first(...).toPromise is not a function
at NgxPermissionsService.hasArrayPermission (ngx-permissions.umd.js:211)
at NgxPermissionsService.hasPermission (ngx-permissions.umd.js:115)
at NgxPermissionsDirective.validateOnlyPermissions (ngx-permissions.umd.js:471)
at SafeSubscriber._next (ngx-permissions.umd.js:433)
at SafeSubscriber.__tryOrSetError (vendor.js?v=al17c1S52F9ckakALoRfjx9ZZ0m1LMiMq-rrE1oO-GM:10843)
at SafeSubscriber.next (vendor.js?v=al17c1S52F9ckakALoRfjx9ZZ0m1LMiMq-rrE1oO-GM:10783)
at Subscriber._next (vendor.js?v=al17c1S52F9ckakALoRfjx9ZZ0m1LMiMq-rrE1oO-GM:10721)
at Subscriber.next (vendor.js?v=al17c1S52F9ckakALoRfjx9ZZ0m1LMiMq-rrE1oO-GM:10685)
at SkipSubscriber._next (skip.js:53)
at SkipSubscriber.Subscriber.next (vendor.js?v=al17c1S52F9ckakALoRfjx9ZZ0m1LMiMq-rrE1oO-GM:10685)
Have somebody any ideas to resolve this issue?
Angular version: 5.1.0-rc.1
ngx-permissions version: ^3.0.0
Browser:
- [x] Chrome (Android) version XX
i have check permission on route. its working file. thanks for your time.
my issue is i load permission list when application startup.
for ex
my current page http://localhost:4200/#/app/users
. now i refresh page redirect on dashboard instead of stay on current page. but i don't know how to resolve this issue. i also try to-load-permissions-before-application-start-up
.
please help me. Thanks in advance
component: UsersComponent, children: [ { path: '', component: UsersListComponent, pathMatch: 'full', canActivate: [NgxPermissionsGuard], data: { permissions: { only: 'read_user', redirectTo: ConfigConstant.DEFAULT_ROUTE }, title: 'Users · Life AI' } },
Angular version:4.0.2
ngx-permissions version: ^1.0.0
ERROR Error: Uncaught (in promise): Error: StaticInjectorError[InjectionToken USE_PERMISSIONS_STORE]:
StaticInjectorError[InjectionToken USE_PERMISSIONS_STORE]:
NullInjectorError: No provider for InjectionToken USE_PERMISSIONS_STORE!
Error: StaticInjectorError[InjectionToken USE_PERMISSIONS_STORE]:
StaticInjectorError[InjectionToken USE_PERMISSIONS_STORE]:
NullInjectorError: No provider for InjectionToken USE_PERMISSIONS_STORE!
at NullInjector.get (core.js:993)
at resolveToken (core.js:1281)
at tryResolveToken (core.js:1223)
at StaticInjector.get (core.js:1094)
at resolveToken (core.js:1281)
at tryResolveToken (core.js:1223)
at StaticInjector.get (core.js:1094)
at resolveNgModuleDep (core.js:10878)
at NgModuleRef.get (core.js:12110)
at resolveDep (core.js:12608)
at NullInjector.get (core.js:993)
at resolveToken (core.js:1281)
at tryResolveToken (core.js:1223)
at StaticInjector.get (core.js:1094)
at resolveToken (core.js:1281)
at tryResolveToken (core.js:1223)
at StaticInjector.get (core.js:1094)
at resolveNgModuleDep (core.js:10878)
at NgModuleRef.get (core.js:12110)
at resolveDep (core.js:12608)
at resolvePromise (zone.js:821)
at resolvePromise (zone.js:785)
at eval (zone.js:870)
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4744)
at ZoneDelegate.invokeTask (zone.js:420)
at Zone.runTask (zone.js:188)
at drainMicroTaskQueue (zone.js:594)
at
hi,
i think that you should cite in the readme that this library should only be used to simplify the client side workflow but not as a security measure because client side checks are not secure at all.
Hi @AlexKhymenko, when will the new version(6.0.0)?
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[x] Feature request
[x] Documentation issue or request
Currently, I do not understand the value of using roles. All directives, guards work on concept of permissions only.
May be I am missing some critical information. Hope to understand the same better. e.g. I can get role and permissions object from backend system. I am able to create roles and corresponding permissions using the APIs described. But can I really use roles in the system? I am right now not sure.. because usage of roles in templates, guards etc is not clearly explained at the moment.
Clear example or documentation on using roles. I am hoping that roles would allow me a shortcut in same directive / guards to specify 10 different permissions.
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
Angular version: X.Y.Z
ngx-permissions version: X.Y.Z
Browser:
- [ ] 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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.