Hi,
The following code does not signed-in the user after a successful change password.
TEST 1ApplicationUser user = await userManager.FindByIdAsync(userId);
user.PasswordHash = userManager.PasswordHasher.HashPassword(user, newPassword);
var result = await userManager.UpdateAsync(user);
if (result.Succeeded) //<<--GOOD return TRUE
TEST 2ApplicationUser user = await userManager.FindByIdAsync(userId);
var token = userManager.GeneratePasswordResetTokenAsync(user).Result;
var result = userManager.ResetPasswordAsync(user, token, newPassword).Result;
if (result.Succeeded) //<<--GOOD return TRUE
TEST 3ApplicationUser user = await userManager.FindByIdAsync(userId);
var resultRemove = await userManager.RemovePasswordAsync(user);
if (resultRemove.Succeeded)
{
var result = await userManager.AddPasswordAsync(user, newPassword);
if (result.Succeeded) //<<--GOOD return TRUE
After testing each Test above then do PasswordSignIn afterwards, the user is not signed-in.
AccountControllervar result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, true, lockoutOnFailure: false);
if (result.Succeeded) //<<--ALWAYS FALSE
Startup.cs
services.Configure<IdentityOptions>(options =>
{
// Password settings
options.Password.RequireDigit = false;
options.Password.RequiredLength = 1;
options.Password.RequiredUniqueChars = 0;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = false;
options.Password.RequireLowercase = false;
// User settings
options.User.RequireUniqueEmail = true;
});
Thanks,