I am creating an entity using Power Tools. How do i capture the current Logged In user 'Id' and 'TennentId' to update the fields the the database for that table
6 Answer(s)
-
0
Hi
You can use the AbpSession extension to get the information of the logged in user. You can get it by calling
AbpSession.GetTenantId()
,AbpSession.GetUserId()
methods. If you want to get UserIdentifier as well. You can use it asAbpSession.ToUserIdentifier()
. -
0
Hi
You can use the AbpSession extension to get the information of the logged in user. You can get it by calling
AbpSession.GetTenantId()
,AbpSession.GetUserId()
methods. If you want to get UserIdentifier as well. You can use it asAbpSession.ToUserIdentifier()
.So you cant get it from Add New Navigation Property in Power Tools?
Select Your Entity Like User (x.x.Authorization.Users.long ?
I would have to create the Property in PowerTool and then update it in code to use
AbpSession.GetUserId()
-
0
Hi
Yes, when creating the relevant entity, you can filter by user by associating the User in the Navigation Property with the user you selected, as you said, you will need to update it manually. Here, you can condition it by taking the logged in user instead of the user information in the input.
-
0
Having problems with Tenantid
AbpSession.GetTenantId()
Do i need to add the TS file and the DTO as well?
-
0
Hi @qquestel
This is not possible with the current version of Power Tools. When you create an entity, if you select one of the 3 options below, AspNet Zero will add
CreationUserId
field to your entity and will set it with the currently logged in user's Id.If your entity is multi-tenant (see screenshot below), the Power Tools will add a TenantId field to your entity and will generate a code block to set it automatically to logged in user's TenantId
If you want to add a custom field for example,
BuyerUserId
and then set it to currently logged in user's Id, you need to modify generated app service code and set it as shown below;yourEntity.BuyerUserId = AbpSession.GetTenantId()
You don't have to add it to creation DTO classes.
-
0
Thank you