فتح مغلق

ABP Roles and permission issue #1163


User avatar
0
kaustubh.kale@ness.com خلقت

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 إجابة (إجابات)
  • User Avatar
    0
    alper خلقت
    فريق الدعم Director

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

  • User Avatar
    0
    ServiceBot خلقت
    فريق الدعم Automatic process manager

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

Made with ❤️ on ABP v8.2.0-preview Updated on مارس 25, 2024, 15:11