Open Closed

ABP Roles and permission issue #1163


User avatar
0
kaustubh.kale@ness.com created

ABP Framework version: v4.2.2 UI type: Angular DB provider: EF Core Tiered (MVC) or Identity Server Seperated (Angular): no / yes Exception message and stack trace: Steps to reproduce the issue:

We have one role anchor admin that user can switch 2 different roles .for achieving this functinality we use ABP patchroute but we when we trying on only on route level using user specific permission it is not working for us.

ABP routes takes entries from policies where we are sending granted entries in grantedpolicies.

How to achive userlevel permission in routing for above scenarion.

PAtch route code:


 patchRoute() {
    const currentmodule = JSON.parse(localStorage.getItem("financeModule"));
    console.log(currentmodule, 'currentmodule')

    const newHomeRouteShowConfig: Partial<ABP.Route> = {
      invisible: false,
      requiredPolicy: 'Litmus.Tenant.AnchorAdmin || Litmus.Tenant.SellerAdmin'
    };

    const newHomeRouteHideConfig: Partial<ABP.Route> = {
      invisible: true,
      requiredPolicy: 'Litmus.Tenant.AnchorAdmin || Litmus.Tenant.SellerAdmin'
    };

    const newInvoiceRouteShowConfig: Partial<ABP.Route> = {
      invisible: false,
      requiredPolicy: 'Litmus.Tenant.SupplierAdmin  || Litmus.Tenant.SellerAdmin || Litmus.Tenant.AnchorAdmin'
    };

    const newInvoiceRouteHideConfig: Partial<ABP.Route> = {
      invisible: true,
      requiredPolicy: 'Litmus.Tenant.SupplierAdmin  || Litmus.Tenant.SellerAdmin || Litmus.Tenant.AnchorAdmin'
    };

    if ((currentmodule === null) || (currentmodule === false)) {

      this.routes.patch('Suppliers', newHomeRouteShowConfig);
      this.routes.patch('Entities', newHomeRouteShowConfig);
      this.routes.patch('Banks', newHomeRouteShowConfig);
      //this.routes.patch('Program', newHomeRouteHideConfig);
      this.routes.patch('Invoices', newInvoiceRouteHideConfig);
      this.routes.patch('Settlement', newHomeRouteHideConfig);
    } else {

      this.routes.patch('Suppliers', newHomeRouteHideConfig);
      this.routes.patch('Entities', newHomeRouteHideConfig);
      this.routes.patch('Banks', newHomeRouteHideConfig);
      //this.routes.patch('Program', newHomeRouteShowConfig);
      this.routes.patch('Invoices', newInvoiceRouteShowConfig);
      this.routes.patch('Settlement', newHomeRouteShowConfig);
    }

  }

Route Code: 
  {
    path: 'invoices',
    component: ApplicationLayoutComponent,
    loadChildren: () => import('./manage-invoice/manage-invoice.module').then((m) => m.ManageInvoiceModule),
    canActivate: [AuthGuard, PermissionGuard, InvoiceGuard],
    data: {
      routes: {
        name: 'Invoices',
        iconClass: 'fa fa-line-chart',
        requiredPolicy: 'Litmus.Tenant.SupplierAdmin  || Litmus.Tenant.SellerAdmin',

      } as ABP.Route,
    },
  },




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

    you can also set specific permission to a user. does it work for you?

  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 19, 2024, 12:56