Base solution for your next web application
Open Closed

Disable Filters for specific Service based on current Tenant #9033


User avatar
0
ajawabra created

I would like to disable filters for Tenants based on current Tenant id, i can acheave that for specific methods, but i would like to apply that for specfic Serivces, simliar to global filter disabling but based on the current Tenant Id

the model i want to apply is: Having Super Admin "Default Tenant" Tenant Users Customers Products so i would like to view all products regardless which tenant it belongs to only for Admin "Default Tenant" and for customers which they will belong to Defualt tenant as well

i have tried Global Filter disabling but i disables it for all the tenants also using CurrentUnitOfWork insdie the service for every single endpoint / method is too much work

Thanks


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can override this method https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.EntityFrameworkCore/EntityFrameworkCore/AbpDbContext.cs#L169 in your DbContext and decide according to your needs to disable filter or not.

  • User Avatar
    0
    ajawabra created

    Hello, I have tried overriding AbpDbContext but it seems that AbpSession doesn't include the TenantId at this point, i'm not sure where is the best place to override this method that allows me to respect the "DependencyLifeStyle" of Transient so i can check that on every request

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can already use GetCurrentTenantIdOrNull() method to get the tenantId correctly. It is in the base DbContext class.