1
I’m using Asp.Net Identity for the first time, along with the Entity Framework, and to create a user, I do the following code:
var identityUser = new IdentityUser
{
UserName = viewModel.Nome.Replace(" ", "."),
Email = viewModel.Email
};
IdentityResult resultado = userManager.Create(identityUser, viewModel.Senha);
Therefore, the user is free to enter his name in the first field viewModel.Nome
and your email in the second viewModel.Email
. To return this user at login, I use the following code:
var usuario = userManager.Find(viewModel.Nome, viewModel.Senha);
My question is: Is it possible to search the user by E-mail, and not by Name? that is, at the time of the Find
change the viewModel.Nome
for viewModel.Email
?
Responding in a simple way, yes. Or, if you like, the version synchronous.
– cosh
@Isaac used an approach based on the link you passed, with some changes. Thank you.
– Ricardo Alves