Open Closed

Query Related to Bulk User Insert #7048


User avatar
0
Exceego created
  • ABP Framework version: v7.3.2
  • UI Type: MVC
  • Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..) / MongoDB
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Our requirement is to insert bulk users. We are using IdentityRepository InsertManyAsync to insert bulk users, it is working good except create password for the users because, we can not assign PasswordHash to IdentityUser entity as it's set parameter is protected and we don't want to use UserManager to create users.

Is there any alternate way to insert bulk users Please advise.


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can inject the IPasswordHasher<IdentityUser> service. Then use ObjectHelper to set the protected property.

    ObjectHelper.TrySetProperty(identityUser, x => x.PasswordHash, () => your_password);

    https://github.com/dotnet/aspnetcore/blob/main/src/Identity/Extensions.Core/src/IPasswordHasher.cs

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11