I created an multi tenant application as per the options shown here in these images in this issue(closed now).
I created a new entity called Gender as per the steps explained in this section. I
I did not want mult-tenant feature on this, so ensured the multi-tenant check box is NOT Selected.
When I run the appication, every thing is working fine.
The host admin is now able to created objects of Gender.
Now I dont want the tenants to create such objects. I logged in as CompanyA/Admin(tenant - CompanyA) and I am able to create Gender.
I want to restrict this. Tenants should not be allowed to create Gender objects while the host should be allowed. How can I achieve that?
Looking at the code, it appears that this should be something to do with Permissions. But I have no clue what do with this.
public class Genders {
public const string Default = GroupName + ".Genders";
public const string Edit = Default + ".Edit";
public const string Create = Default + ".Create";
public const string Delete = Default + ".Delete";
}
One way I found is to ensure that the tenant id is null in the GenderAppService class. If the tenant id is not null, then it means that the user is from a tenant. Then in such a case throw some exception. But this is from the developers perspective. Can the end host admin do something himself to impose such a restriction?
2 Answer(s)
-
0
Ok, one solution I got is the following.
var genderPermission = myGroup.AddPermission(AbpAppTmpltMvcPvtPermissions.Genders.Default, L("Permission:Genders"), MultiTenancySides.Host);
Added the parameter MultiTenancySides.Host.
That file is AbpAppTmpltMvcPvtPermissionDefinitionProvider from the contract project AbpAppTmpltMvcPvt.Application.Contracts and inside Permissions folder.
-
0
that's the good solution