Base solution for your next web application
Open Closed

UserName character restrictions #5895


User avatar
0
PhilWynn created

Hi,

We have a requirement to use email address as User Name.

However, the User Name seems to be restricted to alpha numeric characters only, hence preventing email addresses containing hyphens.

What is the reason for this? Is it possible to override this restriction?

Many thanks.


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @philwynn

    If you are using ASP.NET Core, you can modify AddAbpIdentity like below;

    services.AddAbpIdentity<Tenant, User, Role>(options =>
    {
    	// ....
    	options.User.AllowedUserNameCharacters += @"\"; // doesn't work
    })
    
  • User Avatar
    0
    PhilWynn created

    Hi,

    Sorry, should have mentioned, I am using MVC, jQuery version (Abp v3.8.3)

  • User Avatar
    1
    aaron created
    Support Team

    Answered in this SO question:

    <blockquote>

    This is the default behaviour of ASP.NET (Core) Identity.

    You can do the following to disable validation.

    ASP.NET Core Identity

    IdentityRegistrar.cs:

    return services.AddAbpIdentity&lt;Tenant, User, Role&gt;(options =>
    {
        options.User.AllowedUserNameCharacters = null;
    })
    

    ASP.NET Identity (MVC 5)

    UserManager.cs:

    (UserValidator as Microsoft.AspNet.Identity.UserValidator&lt;User, long&gt;)
        .AllowOnlyAlphanumericUserNames = false;
    

    </blockquote>

  • User Avatar
    0
    PhilWynn created

    Thank you. That solved it...