I have an issue with the standard ASP Identity provider for MVC5. As soon as I log in the method:
await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
keeps returning Failure. So I started debugging, By using:
UserManager.FindByEmail(model.Email);
This returns a valid UserID for my user trying to log in. Then I used:
SignInManager.UserManager.CheckPassword(UserIDObtainedFromFind, model.Password);
And this returns true, which means that the password I provide is valid....
Any ideas on how I can trace, of debug the SignInManager.PasswordSignInAsync method to see where it fails?
SignInManager.PasswordSignIn works off of user name, you should double check that the user name is the same as the email you are passing in.
If username != email
:
ApplicationUser signedUser = UserManager.FindByEmail(model.Email);
var result = await SignInManager.PasswordSignInAsync(signedUser.UserName, model.Password, model.RememberMe, shouldLockout: false);
In my case the same probe validating the email and password, the email is the same as my user.
var userDO = _userManager.FindByEmailAsync(Input.Email).Result;
var validatr = _userManager.CheckPasswordAsync(userDO, Input.Password);
email = userName
true result
Then I checked the database and found that the verification field of the user that did not work is false
Then the verification parameter must be validated in the startup. that is inside the Startup.cs
public void ConfigureServices(ServiceCollection services)
{
//......
services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = false)
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>();
//......
}
The above property setting Gets or sets a flag indicating whether a confirmed IUserConfirmation account is required to sign in
options.SignIn.RequireConfirmedEmail = false;
options.SignIn.RequireConfirmedPhoneNumber = false;
Bye!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With