Open Closed

Override the Permissions grant for super User/Admin (Angular) #1936


User avatar
0
alper created
Support Team Director

We looking forward the sample code on Angular UI to override the Permissions grant for super User/Admin. We did on API side, looking for angular Sample UI.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    On the angular side, we have a service, a guard and a directive responsible for permission management. All you need to do is to replace the service with your own. Here is how you can do it

    First, create a service of your own. Let's call it CustomPermissionService and extend PermissionService from @abp/ng.core as follows:

    import { ConfigStateService, PermissionService } from '@abp/ng.core';
    import { Injectable } from '@angular/core';
    
    @Injectable({
      providedIn: 'root',
    })
    export class CustomPermissionService extends PermissionService {
      constructor(configStateService: ConfigStateService) {
        super(configStateService);
      }
    
      getGrantedPolicy$(key: string) {
        return super.getGrantedPolicy$(key);
      }
    }
    

    And in app.module.ts, provide this service as follows:

    @NgModule({
      // ...
      providers: [
        // ...
        {
          provide: PermissionService,
          useExisting: CustomPermissionService,
        },
      ],
      // ...
    })
    export class AppModule {}
    

    That's it. Now, when a directive/guard asks for PermissionService from angular, it will inject your service.

    For more information about the PermissionService, you can examine it here. https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/services/permission.service.ts

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 21, 2026, 06:18
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.