0
serdar.genc@talentra.net created
Hi,
I added TenantType as an extra property to Tenant. how can i add it to CurrentTenant. I want to call it like this: CurrentTenant.TenantType etc.
- ABP Framework version: v5.0.1
- UI type: MVC
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
3 Answer(s)
-
0
hi
See https://docs.abp.io/en/abp/latest/Authorization#claims-principal-factory
public static class CurrentUserExtensions { public static string GetSocialSecurityNumber(this ICurrentUser currentUser) { return currentUser.FindClaimValue("SocialSecurityNumber"); } }
-
0
Hi @Serdar, you need to override the
CurrentTenant
class, get the tenant by current tenant id and access the Extra Property dictionary of the tenant.[Dependency(ReplaceServices = true)] [ExposeServices(typeof(ICurrentTenant), typeof(CurrentTenant), typeof(MyCurrentTenant))] public class MyCurrentTenant : CurrentTenant { private readonly ITenantRepository _tenantRepository; public MyCurrentTenant(ICurrentTenantAccessor currentTenantAccessor, ITenantRepository tenantRepository):base(currentTenantAccessor) { _tenantRepository = tenantRepository; } public async Task<Dictionary<string, object>> GetExtraProperties() { if(!base.Id.HasValue) { return new Dictionary<string, object>(); } var tenant = await _tenantRepository.GetAsync(base.Id); //implement your logic //tenant.ExtraProperty ... } }
-
0
Hi @Serdar, you need to override the
CurrentTenant
class, get the tenant by current tenant id and access the Extra Property dictionary of the tenant.[Dependency(ReplaceServices = true)] [ExposeServices(typeof(ICurrentTenant), typeof(CurrentTenant), typeof(MyCurrentTenant))] public class MyCurrentTenant : CurrentTenant { private readonly ITenantRepository _tenantRepository; public MyCurrentTenant(ICurrentTenantAccessor currentTenantAccessor, ITenantRepository tenantRepository):base(currentTenantAccessor) { _tenantRepository = tenantRepository; } public async Task<Dictionary<string, object>> GetExtraProperties() { if(!base.Id.HasValue) { return new Dictionary<string, object>(); } var tenant = await _tenantRepository.GetAsync(base.Id); //implement your logic //tenant.ExtraProperty ... } }
tesekkurler @EnginCanV.