- ABP Framework version: v4.4.0
- UI type: Blazor
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
- Exception message and stack trace:
- Steps to reproduce the issue:"
Hello,
I just added a new property (CustomerId) to AbpUser class. But what I really need is a Navigation property in AbpUser to pick up customers in my Customer table. What is the best way to do that in ABP?
public class AppUser : FullAuditedAggregateRoot<Guid>, IUser
{
public virtual Guid? TenantId { get; private set; }
public virtual string UserName { get; private set; }
public virtual string Name { get; private set; }
public virtual string Surname { get; private set; }
public virtual string Email { get; private set; }
public virtual bool EmailConfirmed { get; private set; }
public virtual string PhoneNumber { get; private set; }
public virtual bool PhoneNumberConfirmed { get; private set; }
**public virtual Guid? CustomerId { get; protected set; }**
private AppUser()
{
}
}
8 Answer(s)
-
0
The following docs will help you
- https://docs.abp.io/en/abp/latest/Object-Extensions
- https://docs.abp.io/en/abp/4.4/Module-Entity-Extensions#module-entity-extensions
- https://community.abp.io/articles/how-to-add-custom-property-to-the-user-entity-6ggxiddr
-
0
Thanks for your help. Second link worked for me. I have one more question: Will the new field "CustomerId" be available in current user information? https://docs.abp.io/en/abp/latest/CurrentUser
I need to create a filter with that field to be applied to Customer entity, so I need the field to be extracted from CurrenUser, is that possible?
Thanks,
Nestor
-
0
hi
I need the field to be extracted from CurrenUser
https://github.com/abpframework/abp/issues/42#issuecomment-576025862
-
0
Hello, That solution doesn't work for me. I am not using Claims. I just want to make available a new field I created in AbpUsers entity inside CurrentUser.
Please help!
-
0
hi
The ICurrentUser get info from current claims.
You can add the
CustomerId
to the current claims then get it thoughICurrentUser
https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.Security/System/Security/Principal/AbpClaimsIdentityExtensions.cs#L29
-
0
Hello,
I am still confused about adding CustomerId to current claims. I am new using this framework, I apology for my lack of experience, abp commercial is a really cool framework that I would like to learn how to use it. I have more questions:
- If I use claims, how do I populate/assign the CustomerId to all users? I need to assign a different Customer Id to each user
- Where should I create the class AbpClaimsIdentityExtensions? which project / folder?
- Any code that shows how to extract CustomerId from current claims?
- Any detailed documentation I can use?
Thanks in advance for your help.
Nestor
-
0
Hi,
You can refer the unit tests: https://github.com/abpframework/abp/pull/8153/files#diff-d73ab7794fbad910dc395d2188bdf3692f9a312a4efa69cbdb5cf7be41129ee3R45
-
0
This question has been automatically marked as stale because it has not had recent activity.