Skip to content
This repository has been archived by the owner on Feb 15, 2018. It is now read-only.

Password update failure #27

Open
Xakkep opened this issue Feb 23, 2016 · 2 comments
Open

Password update failure #27

Xakkep opened this issue Feb 23, 2016 · 2 comments
Labels

Comments

@Xakkep
Copy link

Xakkep commented Feb 23, 2016

I start by updating user's password in UI
image
This results in Http Put request to following URL [https://localhost:44340/idm/api/users/ab879063-a184-495b-a99b-4a85e8c96144/properties/cGFzc3dvcmQ]
It then goes to await this.idmService.SetUserPropertyAsync(subject, type, value) and to
SetUserProperty(metadata.UserMetadata.UpdateProperties, user, type, value) in IdentityManager.AspNetIdentity.AspNetIdentityManagerService and eventually to

public virtual IdentityManagerResult SetPassword(TUser user, string password)
{
    var token = this.userManager.GeneratePasswordResetToken(user.Id);
    var result = this.userManager.ResetPassword(user.Id, token, password);
    if (!result.Succeeded)
    {
        return new IdentityManagerResult(result.Errors.First());
    }
    return IdentityManagerResult.Success;
}

However, this.userManager.ResetPassword(user.Id, token, password) will be executed on a different thread, so when public Task SetPasswordHashAsync(TUser user, string passwordHash) in UserStore is called, it'll have another version of user object. Thus when execution successfully returns to SetUserPropertyAsync in IdentityManager.AspNetIdentity.AspNetIdentityManagerService and code about to execute var result = await userManager.UpdateAsync(user); we have original version of user object with old value for PasswordHash property. Thus we endup overwriting PasswordHash again to original value. Password change doesn't work.

Since execution of this.userManager.ResetPassword(user.Id, token, password) is controlled by Microsoft's code how is this problem solved? Am I the only one facing this problem? I'm using MySQL store.

@BruceHunter
Copy link

Does CreateUser work? I'm not having this issue and I'm using MSSql store.

@Xakkep
Copy link
Author

Xakkep commented Mar 21, 2016

CreateUser works.

@brockallen brockallen added the bug label Aug 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants