I am using Asp.Net Identity for the first time, along with the Entity Framework, and to create a user, I make the following code:
var identityUser = new IdentityUser
{
UserName = viewModel.Nome.Replace(" ", "."),
Email = viewModel.Email
};
IdentityResult resultado = userManager.Create(identityUser, viewModel.Senha);
So the user is free to enter his name in the first field viewModel.Nome
and his email in the second viewModel.Email
. To return this user at login time, I use the following code:
var usuario = userManager.Find(viewModel.Nome, viewModel.Senha);
My question is: Is it possible to fetch the user by E-mail, not by Name? that is, at the time of Find
change viewModel.Nome
by viewModel.Email
?