Copied to clipboard

Flag this post as spam?

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


  • CodeMaster2008 151 posts 184 karma points
    Jun 30, 2010 @ 15:03
    CodeMaster2008
    0

    Is MemberShipHelper out of 4.5?

    I came across a few posts were people sugest to use MemberShipHelper to encode a password before save it.
    I started building a test project with 4.1RC and it was there, now that I'm upgrading the test to 4.5, it can't find the MemberShipHelper anymore, looks like it not implemented.

  • CodeMaster2008 151 posts 184 karma points
    Jun 30, 2010 @ 15:39
    CodeMaster2008
    0

    Considering it's missing, how can i encode and save an user password?

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 01, 2010 @ 00:52
    Aaron Powell
    0

    umbraco.cms.businesslogic.member.Member.MemberShipHelper was a horrible hack that was never meant to be exposed to anyone.

    If you are working with members you should be going through the MembershipProvider API. See the wiki as to how to do it: http://our.umbraco.org/wiki/how-tos/membership-providers

  • CodeMaster2008 151 posts 184 karma points
    Jul 01, 2010 @ 01:20
    CodeMaster2008
    0

    Thanks Slace;

    I'm actually working with users (administrators).

    I'd like to change a user password using the API. The thing is the User.Password method will save the password as it is on the database, however, looks like umbraco is expecting a encrypted password (at least it's encrypting the passwords created through the backend.

    I'm looking at the sources right now but i can't find where it encode the password.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 01, 2010 @ 01:29
    Aaron Powell
    0

    Then you should explicitly get the UserMembershipProvider out of the membership provider collection. This is what Umbraco does:

    MembershipUser user = Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].GetUser(this.u.LoginName, true);
    string tempPassword = ((passwordChanger) this.passw.Controls[0]).Password;
    if (!string.IsNullOrEmpty(tempPassword.Trim()))
    {
        if (string.IsNullOrEmpty(this.u.Password))
        {
            this.u.Password = "default";
        }
        user.ChangePassword(this.u.Password, tempPassword);
    }
    
  • CodeMaster2008 151 posts 184 karma points
    Jul 01, 2010 @ 01:44
    CodeMaster2008
    0

    I had tried that already but didn't work as well.
    It won't change the UserPassword field on the umbracoUser table. Looks like to change that i have to set the user.Password property of a User object, however, i need to pass a encoded password to this property (i'm kind of confused here.

    Here is my code:

    Dim uname As String = "myName"
    Dim upass As String = "MyPass"

    Dim umuser As MembershipUser = Membership.Providers(UmbracoSettings.DefaultBackofficeProvider).GetUser(uname, True)
    Dim oldPass As String = umuser.ResetPassword
    umuser.ChangePassword(oldPass, upass)
    Membership.Providers(UmbracoSettings.DefaultBackofficeProvider).UpdateUser(umuser)
  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 01, 2010 @ 06:01
    Aaron Powell
    0

    You don't need to call UpdateUser, otherwise that's pretty much what is done by the back office ASPX page: http://umbraco.codeplex.com/SourceControl/changeset/view/71737#906806

  • CodeMaster2008 151 posts 184 karma points
    Jul 01, 2010 @ 06:34
    CodeMaster2008
    0

    Exactly. I don't understand why it doesn't work. I'm sure I'm still missing something.

Please Sign in or register to post replies

Write your reply to:

Draft