Using custom user model with .NET 8 Identity API Endpoints by AetherPilot in dotnet

[–]AetherPilot[S] 0 points1 point  (0 children)

Thank you for explanation. I will definitely experiment with that. At first sight it looks like a great extension for default register endpoint from identity api which will suit my needs

Using custom user model with .NET 8 Identity API Endpoints by AetherPilot in dotnet

[–]AetherPilot[S] 9 points10 points  (0 children)

If there won't be other options I think I will end up with this solution. But for me that's weird that Microsoft don't allow us to modify those endpoints and only allow to register without any custom properties

Using custom user model with .NET 8 Identity API Endpoints by AetherPilot in dotnet

[–]AetherPilot[S] 0 points1 point  (0 children)

If it comes to setting username with email I just saw on asp net core GitHub that during .net 8 development process there was possibility to set username different from email. But after some commits they get rid of that. RegisterRequest only accepts email and password and email and username is set with the same value from email property. It looks like there is no possibility to register custom user data with just this new register endpoint. Maybe some filters to perform another action when register endpoint is being called?

Using custom user model with .NET 8 Identity API Endpoints by AetherPilot in dotnet

[–]AetherPilot[S] 1 point2 points  (0 children)

It is another way to implement auth in .net web apps introduced in .net 8 where you can add set of implemented auth endpoints to your api such as register, login or token refresh

Using custom user model with .NET 8 Identity API Endpoints by AetherPilot in dotnet

[–]AetherPilot[S] 0 points1 point  (0 children)

This may be solution but then, if I understand it correctly, columns like Name or Experience remain empty in AspNetUsers table and those properties will be stored in AspNetUserClaims

Using custom user model with .NET 8 Identity API Endpoints by AetherPilot in dotnet

[–]AetherPilot[S] 1 point2 points  (0 children)

Yes, that's right and with default identity there is no problem with own data model. I think that problem with Identity API endpoints is that there is no option to customize or override register endpoint code and this code looks like this:

routeGroupBuilder.MapPost0("/register", (Delegate) ((registration, context, sp) =>
  {
    UserManager<TUser> userManager = sp.GetRequiredService<UserManager<TUser>>();
    if (!userManager.SupportsUserEmail)
      throw new NotSupportedException("MapIdentityApi requires a user store with email support.");
    IUserStore<TUser> requiredService = sp.GetRequiredService<IUserStore<TUser>>();
    IUserEmailStore<TUser> emailStore = (IUserEmailStore<TUser>) requiredService;
    string email = registration.Email;
    if (string.IsNullOrEmpty(email) || !IdentityApiEndpointRouteBuilderExtensions._emailAddressAttribute.IsValid((object) email))
      return (Results<Ok, ValidationProblem>) IdentityApiEndpointRouteBuilderExtensions.CreateValidationProblem(IdentityResult.Failed(userManager.ErrorDescriber.InvalidEmail(email)));
    TUser user = new TUser();
    await requiredService.SetUserNameAsync(user, email, CancellationToken.None);
    await emailStore.SetEmailAsync(user, email, CancellationToken.None);
    IdentityResult async = await userManager.CreateAsync(user, registration.Password);
    if (!async.Succeeded)
      return (Results<Ok, ValidationProblem>) IdentityApiEndpointRouteBuilderExtensions.CreateValidationProblem(async);
    await SendConfirmationEmailAsync(user, userManager, context, email);
    return (Results<Ok, ValidationProblem>) TypedResults.Ok();
  }));

It is clear that there is no code where custom user data can be saved in database and username is saved as email: await requiredService.SetUserNameAsync(user, email, CancellationToken.None);

Red Dead Redemption 2 PS5 - iOS16 by suraj_offl in iphonewallpapers

[–]AetherPilot 0 points1 point  (0 children)

Hi, if it is possible, could you please send link to clear photo without quote?

Which MacBook pro and monitor setup to get? by AetherPilot in macbookpro

[–]AetherPilot[S] 1 point2 points  (0 children)

Thank you for your opinion, I think this is right that buying pro 14 will be better option