I am using IdentityServer 3 for authentication. I am storing users in SQL DB using asp.net identity framework. IndentityServer team has provided simple IdentityManager.AspNetIdentity library for administrators to manage users.
I followed the video here and configured my application.
I have my own ApplicationUser
and ApplicationUserManager
class as below
public class ApplicationUser : Microsoft.AspNet.Identity.EntityFramework.IdentityUser
{
}
public class ApplicationUserManager : Microsoft.AspNet.Identity.UserManager<ApplicationUser, string>
{
public ApplicationUserManager(ApplicationUserStore store, IDataProtectionProvider dataProtectionProvider)
: base(store)
{
// Configure validation logic for usernames
UserValidator = new UserValidator<ApplicationUser>(this)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = true
};
// Configure validation logic for passwords
PasswordValidator = new PasswordValidator
{
RequiredLength = 6,
RequireNonLetterOrDigit = true,
RequireDigit = true,
RequireLowercase = true,
RequireUppercase = true,
};
// Configure user lockout defaults
UserLockoutEnabledByDefault = true;
DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5);
MaxFailedAccessAttemptsBeforeLockout = 5;
EmailService = new EmailService();
SmsService = new SmsService();
if (dataProtectionProvider != null)
{
UserTokenProvider =
new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("UserToken"));
}
}
}
When i try to create user, i get error
email cannot be null or empty.
I can get rid of this error by setting RequireUniqueEmail
to false
in ApplicationUserManager
. However that is not my requirement. I want to keep RequireUniqueEmail
to true
Question
How do i get Email address field to appear on create new user page. Note that ApplicationUser
is derived from IdentityUser
that already has Email property. So i am not sure why its not appearing on create new user page?
Update 1
So i looked at the code for new user in github, however its developed in angular. I'm not familiar with angular syntax :( and how the model is passed to view. I am not sure what do i need to do in consumer application to enable email field on new user screen.