Starts in:
2 DAYS
3 HRS
55 MIN
45 SEC
Starts in:
2 D
3 H
55 M
45 S
Open Closed

User Aggregate Questions #4560


User avatar
0
marketbus created
  • ABP Framework version: v7.0.2
  • UI type: Blazor
  • DB provider: EMongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I had a few questions about the User Aggregate and Login:

  1. I would like to ask for the User's Full name at the time of registration. How would I do this?
  2. I would also like to remove the username and use the email address as the username.
  3. When a user registers, I would like to create a stripe "customer" and store that as part of the User object.

Thank you


8 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You should customize the registration page for your case: https://docs.abp.io/en/abp/latest/UI/AspNetCore/Customization-User-Interface

    The Register page is MVC UI

  • User Avatar
    0
    marketbus created

    Which one of the three questions are answering with that link? Number 1?

    Updating the UI is not really a problem, but those changes would have to flow through the system to the database. During registration, only the username, email address, and password will be sent back to the AccountApp service. I would need to include the First and Surname of the user. Would I have to extend the current AccountAppService and override the RegisterAsync method? [Edit] I just looked at the RegisterDto, it doesn't include First or Surname of the user.

    For my 3rd question, for extending the UserIdentity, I can just use SetProperty on the IdentityUser, I believe since I am using MongoDb, it should make a difference in regards to searching by the stripeId as it should just add a property onto the document... correct?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Which one of the three questions are answering with that link? Number 1?

    All questions, RegisterDto is extensible, you can set any properties you need.

    I would need to include the First and Surname of the user. Would I have to extend the current AccountAppService and override the RegisterAsync method

    Yes, you have to.

    For my 3rd question, for extending the UserIdentity, I can just use SetProperty on the IdentityUser, I believe since I am using MongoDb, it should make a difference in regards to searching by the stripeId as it should just add a property onto the document... correct?

    For MongoDB, they are stored as separate fields of the document. https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities#extra-properties

    For example:

    var builder = Builders<IdentityUser>.Filter;
    var query = builder.Eq("stripeId", Value);
    var users = await (await userRepository.GetCollectionAsync()).Find(query).ToListAsync();
    
  • User Avatar
    0
    marketbus created

    Thanks...

    There are several places in the UI that uses first name. So I am assuming that I would have to override all of those components with new ones as in https://docs.abp.io/en/abp/latest/UI/Blazor/Customization-Overriding-Components?UI=BlazorServer

    ABP has excellent localization support. But I believe not using FullName might be a miss. The concept of surname and name changes quite a bit depending on local. Certain parts of Europe, Latin America, East Asia, etc don't use the standard name, surname format.

    Also is there anyway to query ExtraProperties using the default repositories? I am assuming I would have to create a MyIdentityUserRepository that inherits from IdentityUserRepository and override the GetListAsync method or Add my own GetListWithExtraAsync and include stripeId and fullName, for example.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    There are several places in the UI that uses first name. So I am assuming that I would have to override all of those components with new ones as in https://docs.abp.io/en/abp/latest/UI/Blazor/Customization-Overriding-Components?UI=BlazorServer ABP has excellent localization support. But I believe not using FullName might be a miss. The concept of surname and name changes quite a bit depending on local. Certain parts of Europe, Latin America, East Asia, etc don't use the standard name, surname format.

    Yes, you need to override the pages, ABP cannot cover all situations, but you can customize it according to your own needs

    Also is there anyway to query ExtraProperties using the default repositories? I am assuming I would have to create a MyIdentityUserRepository that inherits from IdentityUserRepository and override the GetListAsync method or Add my own GetListWithExtraAsync and include stripeId and fullName, for example.

    No, you don't need it. it is already included in the entity data

    //GET AN EXTRA PROPERTY
    var user = await _identityUserRepository.GetAsync(userId);
    return user.GetProperty<string>("Title");
    
  • User Avatar
    0
    marketbus created

    Let me clarify my last question. I would like to query on the extra property. So for example, if I wanted to query on where fullname = "Tom" or stripeId = "123".

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi, you can try :

    var builder = Builders<IdentityUser>.Filter;
    var query = builder.Eq("stripeId", Value);
    var users = await (await userRepository.GetCollectionAsync()).Find(query).ToListAsync();
    

    To use GetCollectionAsync method in the app service or domain, you need to reference the Volo.Abp.MongoDB package

    More example: https://www.mongodb.com/docs/drivers/csharp/current/fundamentals/crud/read-operations/retrieve/#example

  • User Avatar
    0
    marketbus created

    Thanks.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06