U4-4956 - UserService.SavePassword method always throws a not supported exception

Created by Tim Anderson 20 May 2014, 15:46:40 Updated by Tim Anderson 29 May 2014, 12:07:21

I have been trying to migrate my code to the new member service while upgrading our umbraco 6.1.6 build to 6.2.0. Having looked at the Umbraco source code on GitHub it appears that the exception at the end of the method is executed regardless of success of failure of the method resulting in an exception being thrown for every call for this method:

public void SavePassword(IUser user, string password) { if (user == null) throw new ArgumentNullException("user");

        var provider = MembershipProviderExtensions.GetUsersMembershipProvider();
        if (provider.IsUmbracoMembershipProvider())
        {
            provider.ChangePassword(user.Username, "", password);
        }

        //go re-fetch the member and update the properties that may have changed
        var result = GetByUsername(user.Username);
        if (result != null)
        {
            //should never be null but it could have been deleted by another thread.
            user.RawPasswordValue = result.RawPasswordValue;
            user.LastPasswordChangeDate = result.LastPasswordChangeDate;
            user.UpdateDate = user.UpdateDate;
        }

        // This line appears to execute regardless of success of failure of the code above.....
        throw new NotSupportedException("When using a non-Umbraco membership provider you must change the user password by using the MembershipProvider.ChangePassword method");
    }

Not being a user of Umbraco 7 as yet, not sure if any Umbraco 7 builds are also affected by this issue as well.

Comments

Sebastiaan Janssen 27 May 2014, 09:52:12

Fixed in 13e8e972ebbf2f18199566327af605a3ec1f790b (v6) and 2496a8e77e22c2e81cc03399cd7a8bee081298af (v7)


Sebastiaan Janssen 27 May 2014, 09:56:02

Important to note that this is for backoffice users, not (frontend) members! So make sure you're using the correct methods.


Tim Anderson 29 May 2014, 12:07:21

Noted :-), I was indeed working with the backoffice users on this particular occasion!


Priority: Normal

Type: Exception

State: Fixed

Assignee:

Difficulty: Normal

Category: Architecture

Backwards Compatible: True

Fix Submitted: None

Affected versions: 6.2.0

Due in version: 6.2.1, 7.1.4

Sprint:

Story Points:

Cycle: