Identity icon indicating copy to clipboard operation
Identity copied to clipboard

UserManager<ApplicationUser>.CheckPasswordAsync alway returns false

Open gisek opened this issue 11 years ago • 2 comments

The code below always produces false (also for valid credentials)

var user = new ApplicationUser { Email = model.Email};
var credentialsCorrect = await _userManager.CheckPasswordAsync(user, model.Password);
// credentialsCorrect  is always false

On the other hand, if I use SignInManager<ApplicationUser> instead, the code below works fine

var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);
var credentialsCorrect = result.Succeeded;

gisek avatar Oct 03 '15 19:10 gisek

If you check code the SignInManager class it performs a FindByNameAsync to retrieve the user.

https://github.com/aspnet/Identity/blob/acfee9e7e05bfb8ef25c8a7628c200c4cc715ff0/src/Microsoft.AspNet.Identity/SignInManager.cs#L239-L248

dcarr42 avatar Oct 03 '15 21:10 dcarr42

@DAllanCarr You are right. I was using it the wrong way. The issue should be closed.

gisek avatar Oct 03 '15 22:10 gisek