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.

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

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
    })
    
    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    PhilWynn created

    Hi,

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

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • 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>

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    PhilWynn created

    Thank you. That solved it...

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)