Giter Site home page Giter Site logo

alexkhymenko / ngx-permissions Goto Github PK

View Code? Open in Web Editor NEW
922.0 25.0 124.0 4.46 MB

Permission and roles based access control for your angular(angular 2,4,5,6,7,9+) applications(AOT, lazy modules compatible

License: MIT License

JavaScript 0.75% TypeScript 96.56% HTML 2.67% SCSS 0.02%
angular2 ngx-permissions angular2-permissions ng2-permissions angular ngx-permission ng-permission permissions angular4 angular5

ngx-permissions's People

Contributors

alexkhymenko avatar dependabot[bot] avatar georgeknap avatar jkubiszewski avatar jrmlstf avatar kirjs avatar phra avatar sholvabai avatar thekiba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-permissions's Issues

TestModule

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

No test support.

Expected behavior

It would be nice with mock module or the likes, so that:

  • the directives would be valid (and hence the test can be setup)
  • a mock permission evaluation, which would always allow access

Environment


Angular version: 5.2.1
ngx-permissions version: 3.1.0

Browser:
All

Role Based Component

``

I'm submitting a...

Current behavior

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?

ngxPermissionsOnly not working in template

How I used -

<p ngxPermissionsOnly="GUEST">Members online</p>

Permissions set in component and added role as below -

NgxPermissionsService.loadPermissions(["A"]); NgxRolesService.addRole('ADMIN', ['A'] );

Code added in component to check role is added in permission or not -

let roles = NgxRolesService.getRoles();
NgxRolesService.roles$.subscribe((data) => { console.log(data); })

console.log returns below -

{ "ADMIN": { "name": "ADMIN", "validationFunction": [ "A" ] } }

Can you replicate this issue and let me know possible solution for this.

Tried following possibilities -

<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.

View restriction permissions break on refresh

I'm submitting a...


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

Current behavior

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.

Expected behavior

ngxPermissionsOnly should show and hide elements consistently regardless of page refresh and navigation

Minimal reproduction of the problem with instructions

  1. Load permissions using addPermission or loadPermissions
  2. Use ngxPermissionsOnly directive in a view to show or hide an element
  3. Navigate to page using ngxPermissionsOnly --> Element is shown since user has correct permissions
  4. Refresh page
  5. Now element is hidden even though user has permissions

Code:
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>

Environment


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
  
  

3.2.0 is not including new NgxPermissionsAllowStubDirective, NgxPermissionsRestrictStubDirective with NgxPermissionsModule.

I'm submitting a...


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

Current behavior

Version 3.2.0 is not including new NgxPermissionsAllowStubDirective, NgxPermissionsRestrictStubDirective with the NgxPermissionsModule.

Expected behavior

I am sure you just forgot to add this?

Minimal reproduction of the problem with instructions

Environment



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

Issue with get permissions

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

Permissions doesn't persist

I'm submitting a...


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

Current behavior

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

Expected behavior

The permissions should persist even when we change the navigation

Minimal reproduction of the problem with instructions

Environment


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

Unable to get directive to work, Angular 6

I'm submitting a...


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

Current behavior

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?

Expected behavior

Desired result is that the directive works without errors

Minimal reproduction of the problem with instructions

Follow steps above in current behavior.

Environment


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

TypeError: rxjs_Observable.Observable.merge(...).mergeAll is not a function

I'm submitting a Bug report

my code in my component (bandeau-qoq.component.ts)

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

my code in the template (bandeau-qoq.component.html)

<ng-container *ngxPermissionsOnly="['ADMIN']">

Current behavior

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)

Environment


Angular version: 4.0.0
ngx-permissions version: 2.1.0


Browser: Chrome (desktop) version 61.0.3163.100 (Build officiel) (32 bits)

*ngFor

Hi,

it seems, the directives (eg. ngxPermissionsOnly) cannot be used within an "*ngFor" loop.

Example:
...*ngFor="let child of children" ..

{{child.value}}

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

How to listen permissionsAuthorized event

I'm submitting a...


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

Current behavior

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.

Expected behavior

I need to listen when permission is granted.

Minimal reproduction of the problem with instructions

Template side:
<li *ngxPermissionsOnly="'canAccessSettings'" (permissionsAuthorized)="reloadMenu()">Item<li>

Component side:
public reloadMenu($event): void { console.log('reloadMenu', $event); }

Environment


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

Is there any possibility for strict roles with shared permission?

I'm submitting a...


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

Current behavior

Validation passes if permission is common for different roles

Expected behavior

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.

Minimal reproduction of the problem with instructions

Environment


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

Get permissions after page refresh

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?

Please release v6 as rxjs 6 has been released and it is not compatible with current version

I'm submitting a...


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

Current behavior

Does not work with rxjs 6.0

Expected behavior

Minimal reproduction of the problem with instructions

Environment


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

Role Based Button Disable !!!!!!!

Hai Alex,

I am using your library is there any possibility for user role Based Button disabled.

Please advice . Using permissionsAuthorized and permissionsAuthorized

User has permission to current route

I'm submitting a...


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

Current behavior

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?

Expected behavior

Minimal reproduction of the problem with instructions

Environment


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

Support for loading the role / permission during the route guard check

  • make sure you have the correct permission
  • go to a url with permission guard on it using that permission
  • refresh the page
    ==> In my use case, there is no way I can load the permission fast enough because I cannot load the permission at application start. I need a way to be able to check permission with the server using the permission guard.

I'm submitting a...


[X ] Feature request

Current behavior

Not currently possible

Expected behavior

Environment


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

Observable.merge AOT compilation

I'm submitting a...


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

Current behavior

If i compile project with aot (--prod) flag. I got error in browser console Observable.merge is not a function in validateExceptOnlyPermissions

Expected behavior

Minimal reproduction of the problem with instructions

Environment


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

Guard and Directive use different logical operator

I'm submitting a...


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

Current behavior

<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)..

Expected behavior

They should work the same

Minimal reproduction of the problem with instructions

Environment


Angular version: @angular/cli: 1.4.6
ngx-permissions version: 2.1.1

Always check by lower level of role

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

CanLoad functionality

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

Question

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!

Unauthorized Strategies

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!

rxjs.merge is not a function at NgxPermissionsDirective.validateExceptOnlyPermissions (ngx-permissions.umd.js:632)

I'm submitting a...

update angular 4.2 to 5.2.8 and update ngx-permisison package but not working a

Current behavior

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)

Expected behavior

it should be work fine with angular 5.2.8

Environment


Angular version: 5.2.8
ngx-permissions version: X.Y.Z
 rxjs: 5.5.6

Browser:
- [ ] Chrome (desktop) version XX

Can't access component variables

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

Usage of roles

I'm submitting a...


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

Current behavior

Neither the directives ngxPermissionsOnly, ngxPermissionsExcept, nor except and only with routes work when using roles. Neither the plunker demo is working with roles.

Expected behavior

When user adds roles using their service, from the documentation it seems, they should be appliable as well as permissions added using their service.

Minimal reproduction of the problem with instructions

Go to roles page
https://plnkr.co/edit/n6Wa6hXg0JzI6e050wBt?p=preview

Environment


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

redirectTo with query parameters

I'm submitting a...


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

Current behavior

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.

Expected behavior

{
			path: 'test/:id',
			component: testComponent,
			canActivate: [NgxPermissionsGuard],
			data: {
				permissions: {
					only: ["ROLE_USER"],
					redirectTo: ['/login'] // would like to redirect to /login?not_authorized=1 
				}
			}
		},

Minimal reproduction of the problem with instructions

Environment


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

ngx-permissions - NgxPermissionsGuard routing issue redirect to default route.

Current behavior

We have 3 child route and 1 root route

  1. oneadmin/login
  2. twoadmin/login
  3. site/login
  4. app route for root and lazy loading

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);

Expected behavior

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

Environment


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)

Move plunker to statblitz

I'm submitting a...


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

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

Environment


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

How can use "canDoSomething" permission without role into the view ?

I'm submitting a...


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

Current behavior

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 :)

Expected behavior

Minimal reproduction of the problem with instructions

Environment


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

Issue on refresh page with Implemented Guards

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

Role based permmisions

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

Whether I can give variables here without hardcoding the permissions for routes?

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?

can I use 'and' with ngxPermissionsOnly

I'm submitting a...


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

Current behavior

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.

Expected behavior

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

Correct Implementation of load permissions after login (authentication)

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 ?

How can i use NgxPermissionsAllowStubDirective ? Can you please provide the plunker ?

I'm submitting a...


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

Current behavior

Normally it is working fine but in the unit test i am not able to bypass the directive condition. How can i bypass it

Expected behavior

Minimal reproduction of the problem with instructions

<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

Environment


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

Override NgxGuardPermissions

Hello, everyone!

I would like to know could I override the NgxGuardPermissions? I just want to make logout if permission is denied.

Thanks!

loadPermissions not removing old permissions

I'm submitting a...


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

Current behavior

In the Multiple Permissions section of the docs it states that loadPermissions "will remove older permissions and pass only new"

Expected behavior

loadPermissions should remove older permissions and replace with the new

Minimal reproduction of the problem with instructions

this.ngxPermissionsService.loadPermissions(['admin', 'test']);
this.ngxPermissionsService.loadPermissions(['another', 'random']);
// 'admin' and 'test' permissions still exist

Component with onpush requires detect changes

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 ?

Ownership-based access

I'm submitting a...


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

Current behavior

How to implement the ownership-based access control, allowing for example only the owner to edit
a specific resource?

Expected behavior

I would allow to edit a resource

  • all the administrators
  • the specific owner (cannot filter by role, need to filter comparing the current user with the user pointed as owner from the resource)

can we build hierarchy?

I'm submitting a...


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

Expected behavior

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'])

Component loaded twice

I'm submitting a...


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

Current behavior

When I use lib to restrict access to a component, this component will be loaded twice if access is granted

Expected behavior

The component should be loaded only once.

Minimal reproduction of the problem with instructions

<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.

Environment


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
  

v5.0.0-rc.0 does not work with rxjs6

I'm submitting a...


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

Current behavior

v5.0.0-rc.0 does not work with rxjs6

Expected behavior

Minimal reproduction of the problem with instructions

Environment


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

rxjs_Observable.Observable.merge(...).mergeAll(...).first(...).toPromise is not a function

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?

Environment


Angular version: 5.1.0-rc.1
ngx-permissions version: ^3.0.0


Browser:
- [x] Chrome (Android) version XX

HELP : When refresh page its redirect on dashboard

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

No provider for InjectionToken USE_PERMISSIONS_STORE

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

add disclaimer about insecure client permissions

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.

Usage of roles

I'm submitting a...


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

Current behavior

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.

Expected behavior

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.

I have quick question i have loaded my roles via the RolesService how do i use or check against them say in the html template. For permissions it's simple by using the Permission directive. but for roles what do you use?

I'm submitting a...


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

Current behavior

Expected behavior

Minimal reproduction of the problem with instructions

Environment


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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.