Copied to clipboard

Flag this post as spam?

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


  • Evan 344 posts 99 karma points
    Apr 20, 2009 @ 20:45
    Evan
    0

    Password Recovery for a membership login v4.0.1

    How can I write a password recovery in version 4.0.1? I can not get it to work with hashed passwords...

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Apr 20, 2009 @ 22:21
    Dirk De Grave
    0

    Hi Evan,

    Hashed password cannot be recovered! It's a one way encryption, so decrypting it is impossible. Password reset however should be possible in that case.

    Cheers,
    /Dirk

  • Evan 344 posts 99 karma points
    Apr 20, 2009 @ 22:24
    Evan
    0

    [quote=Dirk]Hi Evan,

    Hashed password cannot be recovered! It's a one way encryption, so decrypting it is impossible. Password reset however should be possible in that case.

    Cheers,
    /Dirk

    [/quote]
    Ok, I dont foresee that as being a big deal at all, thanks.

    Evan

  • Paul Blair 466 posts 731 karma points
    Apr 21, 2009 @ 05:23
    Paul Blair
    0

    I was using the PasswordRecovery control and for it wasn't resetting the members password in Umbraco.

    Therefore I hooked into the OnSendingMail event to get the password from the email body and explicitly set in in Umbraco.

    initially I tried calling the ResetPassword Membership function and this didn't work (which I suspect is why the password is not set by the control - perhaps this hasn't been defined correctly in the Umbraco provider).

    here is my code that currently does the job:
    [code]
    protected void OnSendingMail(object sender, MailMessageEventArgs e)
    {
    string newPassword = "";
    Regex rgxLines = new Regex("\n");
    string[] arrSegments = rgxLines.Split(e.Message.Body);
    // extract the password from the email
    for (int i = 0; i < arrSegments.Length; i++)
    {
    if (arrSegments[i].IndexOf("Password: ") >= 0)
    {
    newPassword = arrSegments[i].Substring(arrSegments[i].IndexOf("Password: ") + 10, arrSegments[i].Length-10);
    break;
    }
    }

    TextBox userName = (TextBox)PasswordRecovery1.UserNameTemplateContainer.FindControl("UserName");
    // Need to reset it here so it gets hashed in the DB
    Membership.Provider.ChangePassword(userName.Text, newPassword, newPassword);

    HyperLink btnLogin = (HyperLink)PasswordRecovery1.SuccessTemplateContainer.FindControl("btnLogin");
    btnLogin.NavigateUrl = SSLPath.NiceUrlFullyQualifiedPath(iLoginPageID, true, false, false);
    }
    [/code]

    You also need to make enablePasswordReset="true" in the UmbracoMembershipProvider section of the web.config

  • 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