I am using the below atricle to implement Organization filter :
https://aspnetboilerplate.com/Pages/Documents/Articles\How-To\add-custom-data-filter-ef-core
Everything works fine, but I would like to know how to update the user's claim.
4 Answer(s)
-
0
hi maharatha
You can refer to this issue https://github.com/aspnetboilerplate/aspnetboilerplate/issues/5092#issuecomment-562006265
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
This is the approach i am taking :
var userOuClaim = PrincipalAccessor.Principal?.Claims.FirstOrDefault(c => c.Type == "Application_OrganizationUnitId"); if (AbpSession.UserId.HasValue && AbpSession.TenantId.HasValue) { var currentUserOrgId = _cacheManager.GetCache(PSLConsts.UserOrganizationCache) .GetOrDefault(AbpSession.UserId.Value.ToString() + AbpSession.TenantId.Value); if (currentUserOrgId != null) { return Convert.ToInt32(currentUserOrgId); } if (string.IsNullOrEmpty(userOuClaim?.Value)) return null; _cacheManager.GetCache(PSLConsts.UserOrganizationCache).Set(AbpSession.UserId.Value.ToString(), userOuClaim.Value); return Convert.ToInt32(userOuClaim.Value); } if (AbpSession.UserId.HasValue && !AbpSession.TenantId.HasValue) { var currentUserOrgId = _cacheManager.GetCache(PSLConsts.UserOrganizationCache) .GetOrDefault(AbpSession.UserId.Value.ToString()); if (currentUserOrgId != null) { return Convert.ToInt32(currentUserOrgId); } if (string.IsNullOrEmpty(userOuClaim?.Value)) return null; _cacheManager.GetCache(PSLConsts.UserOrganizationCache).Set(AbpSession.UserId.Value.ToString(), userOuClaim.Value); return Convert.ToInt32(userOuClaim.Value); }I am somehow not convinced with the elegence of the solution. Is there a better way. The idea is to set the Orgid when the user changes the Org or fall back to Default orgID. This is applicable for Host and Tenant
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
I don't think you should use PrincipalAccessor but use cache directly.
Use TenantId and UserId as cache keys.
var cacheKey = $"{AbpSession.TenantId ?? 0}_{AbpSession.UserId.Value.ToString()}";Read userOu from cache just like custom session. Update the cache when userOu changes.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
This issue is closed because it has not had recent activity for a long time.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)