Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1347 posts 1608 karma points
    Jul 24, 2012 @ 01:10
    Gordon Saxby
    0

    Change User password via API

    I am trying to change the password of a User (not Member) in a UserControl but it does not seem to be working.

    I found this post http://our.umbraco.org/forum/developers/api-questions/10247-Is-MemberShipHelper-out-of-45 and used the same / similar code but the password doesn't change ... ?

  • Lennart Stoop 304 posts 841 karma points
    Jul 24, 2012 @ 09:45
    Lennart Stoop
    0

    Hi Gordon,

    If I remember correctly you can get the user from the membership provider and update the password directly, much like this:

    MembershipUser user = Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].GetUser("login", true);

    user.Password = "newpassword";

    user.Save();

     

    Grtz

    L

     

     

  • Gordon Saxby 1347 posts 1608 karma points
    Jul 24, 2012 @ 10:07
    Gordon Saxby
    2

    OK ... problem solved!

    The issue was that the password was not being hashed when assigned / saved. The above code is one option I tried but the password was entered into the database as plain text. The solution was found here http://our.umbraco.org/wiki/reference/api-cheatsheet/users,-user-types-and-permissions/add-user-with-hashed-password

    I have implemented similar code and it appears to work fine!

                var u = new User(LoginName);
                u.Password = HashPassword(newPwd);
                u.Save(); 
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies