Open Closed

Login Identity.DuplicateEmail #181


0
hans abelshausen created

Hi, we are using module Zero for Login. We only need the Name as required. So I overwrited the mail with: [Required(AllowEmptyStrings = true)] public override string EmailAddress { get; set; }

But now, if two people leave the mail field empty, the user is not saved to db. Is there a way to stop watching the DuplicateEmail functionality?


1 Answer(s)
  • 0
    hikalkan created

    You can try to override CheckDuplicateUsernameOrEmailAddressAsync in your UserManager class. It's default implementation is like that (defined in https://github.com/aspnetboilerplate/mo ... er.cs#L460):

    public virtual async Task<IdentityResult> CheckDuplicateUsernameOrEmailAddressAsync(long? expectedUserId, string userName, string emailAddress)
            {
                var user = (await FindByNameAsync(userName));
                if (user != null && user.Id != expectedUserId)
                {
                    return AbpIdentityResult.Failed(string.Format(L("Identity.DuplicateName"), userName));
                }
    
                user = (await FindByEmailAsync(emailAddress));
                if (user != null && user.Id != expectedUserId)
                {
                    return AbpIdentityResult.Failed(string.Format(L("Identity.DuplicateEmail"), emailAddress));
                }
    
                return IdentityResult.Success;
            }
    

    You can override and change behaviour (so, don't call base method in override).