Configure Microsoft.AspNet.Identity to allow email address as username

前端 未结 13 2031
时光取名叫无心
时光取名叫无心 2020-11-28 20:08

I\'m in the process of creating a new application and started out using EF6-rc1, Microsoft.AspNet.Identity.Core 1.0.0-rc1, Microsoft.AspNet.Identity.EntityFramework 1.0.0-rc

13条回答
  •  萌比男神i
    2020-11-28 20:50

    In my case i had a repository class working with authentication, that didn't let me use a "-" inside usernames.. The fix was inside the constructor here:

    //-------------------------------------------------------
    public AuthRepository()
    //-------------------------------------------------------
    {
        _ctx = new AuthContext();
        _userManager = new UserManager(new UserStore(_ctx));
        _userManager.UserValidator = new UserValidator(_userManager)
        {
            AllowOnlyAlphanumericUserNames = false
        };
    }
    

提交回复
热议问题