I want to save user without email, like this:
var user = new ApplicationUser { UserName = model.Name };
var result = await UserManager.CreateAsync(user);
Identity depends on email as a way to reset user password.
However, ignoring email is not simple, but possible. You'll need to implement Microsoft.AspNet.Identity.IIdentityValidator
interface that ignores the lack of email:
namespace Microsoft.AspNet.Identity
{
///
/// Used to validate an item
///
///
///
public interface IIdentityValidator
{
///
/// Validate the item
///
///
///
///
Task ValidateAsync(T item);
}
}
And then in ApplicationUserManager
assign your own implementation to property UserValidator
.
If you really need this, you can get the original source code for UserValidator
by decompiling Microsoft.AspNet.Identity.UserValidator
class and peeking into the existing source code and removing cheecking for email.
However, I'm not sure how the rest of the framework will react on lack of email on user. Probably you'll get exceptions in other operations.