Abp: How can get the current login user organization

Created on 15 Jun 2020  路  2Comments  路  Source: abpframework/abp

How can i get the current login user organization. I did not find an organizational acquisition method from the interface ICurrentUser. Are there any other places?

question

Most helpful comment

You can custom UserClaimsPrincipalFactory to add current user's organization to the claims when login. like this:
https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory.cs

Then you can use FindClaimValue extension method to get current user's organization

All 2 comments

You can custom UserClaimsPrincipalFactory to add current user's organization to the claims when login. like this:
https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory.cs

Then you can use FindClaimValue extension method to get current user's organization

Or use IdentityUserManager.GetOrganizationUnitsAsync method to query it (cache it if you need performance).

Was this page helpful?
0 / 5 - 0 ratings