common roles for all tenants in AspNetBoilerplate

573 views Asked by At

I have a custom set of roles that is supposed to be used in a multi-tenant app.

AbpRoles table has a column titled "TenantId" (nullable).

Problem is that if I leave this field with a null value, a user per certain tenant cannot be recognized as being related to a certain role. But if an AbpRole record has tenant id value - all works pretty well.

The bottomline is:

my code has to be creating the same set of roles for each tenant, so I'm just wondering if it's possible to have common set of roles for all tenants.

If the TenantId value is null for AbpRole record and I wrap the code that checks if user belongs to a role

User.IsInRole("Employee")

into this block

using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))

the problem is still not solved.

1

There are 1 answers

0
Alper Ebicoglu On BEST ANSWER

Sorry for late answer. For the guys looking an answer for this question; Roles should be created per tenant. If you are using single tenant then you have use the Default tenant's id. As a result you can not share a role. If you insist on sharing roles btw tenants you have to disable MayHaveTenant everytime you make operation on role.