Skip to content

[Identity] Allow Email-Only Authentication Without Mandatory Username Field #60787

@Imorales0210

Description

@Imorales0210

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Hello Everyone!

Problem Description

When creating a RESTful API with .NET Core and Identity, the UserManager requires a value for the UserName field even if it is explicitly removed from the user entity. Current community solutions involve:

  • Manually setting the UserName to the user’s email (with sanitized characters) or
  • Creating a custom UserValidator to bypass the requirement.

While these workarounds function, they feel hacky and counterintuitive for modern authentication flows where email/password is standard and username/password is less common.

Describe the solution you'd like

Expected Behavior
The UserManager should allow developers to configure authentication to use email-only (without requiring UserName). Example:

services.Configure<IdentityOptions>(options => {  
    options.User.RequireUserName = false; // Hypothetical  
});  

Current Behavior
The UserName field is mandatory, forcing developers to implement non-standard workarounds.

Proposed Solution
Add a configuration parameter to IdentityOptions to control whether authentication uses:

  • UserName only
  • Email only
  • Both

This would align with modern authentication patterns and reduce boilerplate code.

Additional context

Research links:

  1. https://stackoverflow.com/a/19460800
  2. https://stackoverflow.com/a/78826649

Lastly, thanks for your time and if you have a better solution please share it with me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackThe author of this issue needs to respond in order for us to continue investigating this issue.Status: No Recent Activityarea-identityIncludes: Identity and providers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions