Hi, What is the expected behavior when I call getAll over an entity with IMustHaveTenant interface anonymously?
So the user calls GetAll over this entity without logging in first and service allows the call since its marked as AllowAnonymous. Should I expect to get all items(of all tenants) or nothing?
thanks
4 Answer(s)
-
0
Hi @uenlkr4e
The Entity implemented with the IMustHaveTenant interface is created in isolation among Tenants. When a non-logged-in user makes a request, no record will be returned since the TenantId will be null. If you want, you can set a Default tenant for anonymous users. If you want to separate this entity for both non-logged-in and logged-in users, you can use IMayHaveTenant. When the TenantId is passed as null, the relevant entity is isolated on the Host side.
Related Document
Related Document
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
that really helps, thank you
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi, one more quick question about this: say the entity implements IMustHaveTenant and an anonyms call is made to it where the tenant id in session is null. but i modify the query by adding tenantId to it. does it override the imusthavetenant filter? or abp doesnt care about my manual filter statement and always applies its tenant filter?
thanks
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi
When you use IMustHaveTenant Abp always applies its tenant filter, regardless of your manual filter. If the current session has TenantId = null (anonymous call or host user), the tenant filter will automatically filter out tenant-specific entities unless you explicitly disable it. Your manual filter will be combined with Abp filter. Abp filter takes precedence, so even if you add a manual TenantId filter, the framework will still enforce its IMustHaveTenant rules. To override Abp automatic tenant filter, you need to use the DisableFilter method. If you want to filter by the logged-in user in some cases and by the Tenant you specify in some cases, you can use DisableFilter here. Related Document Disable Filter
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)