Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 karma points
    Aug 26, 2009 @ 09:08
    Claushingebjerg
    0

    Member password reminder not sending info

    Im using the Member control package by Niels, but the Password reminder function doesnt seem to actually send out the forgotten password.

    I get an email, with the text i defined on the maco, but the password is not in the mail?!?!

    Any ideas. its 4.0.2.1

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 26, 2009 @ 10:44
    Dirk De Grave
    0

    Hi,

    Can't offer advice on your problem, but why aren't you using the asp.net controls for recovering passwords? It's dead drop easy, no need for any additional code. Also, be sure that password recovering is not possible when passwordFormat="Hashed"!!

     

    Cheers,

    /Dirk

  • Claushingebjerg 939 posts 2574 karma points
    Aug 27, 2009 @ 15:24
    Claushingebjerg
    0

    Because im a designer, not a devolper :)

    And because the membercontrols is a repository package, and i therefore thought it would be "Best practice" to use this.

    I've now changed the following in the web config:

      <add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="true" enablePasswordReset="false" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Another Type" passwordFormat="Clear" />

    But i still dont get the info in the mail.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 27, 2009 @ 16:13
    Dirk De Grave
    100

    Ok, you're not a developer... but it doesn't actually require programming knowledge, it's just a plain asp.net control which you drop onto a template and set some properties and that's it!

     

    <asp:PasswordRecovery ID="PasswordRecovery1" runat="server" MailDefinition-BodyFileName="RelativePathToFile" />

     

    Some references: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.passwordrecovery.maildefinition.aspx and http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.maildefinition.bodyfilename.aspx

    Don't know much about the functioning of the membercontrols package from the repo, so not sure whether those use the membership provider info found in web.config

     

    Cheers,

    /Dirk

  • Claushingebjerg 939 posts 2574 karma points
    Aug 28, 2009 @ 13:57
    Claushingebjerg
    0

    Cool, it works, thanks

  • Claushingebjerg 939 posts 2574 karma points
    Sep 07, 2009 @ 08:37
    Claushingebjerg
    0

    Is it possible to rertrive the infor using the memebers email instead of username? Mu members always forget their username, but can always remember their email

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 07, 2009 @ 09:22
    Dirk De Grave
    0

    Yes, that's possible but will require some coding from your part.

    PasswordRecovery has a bunch of events that fire when using it, one of those is the VerifyingUser event which is triggered just before the user name is sent to the Membership provider. In your case, you'll have to perform an additional lookup on the member (find username from email) and send that info instead of e-mail (as the membership provider will only look at the username provided through the control)

    And, you'll have to change the layout slightly (UserNameTemplate)

    I don't have any example here atm (have already done exactly the same thing in another project) but can dig that up for you tonight. Send me a mail at dirk at netaddicts dot be if you want it.

     

    Cheers,

    /Dirk

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 07, 2009 @ 21:10
    Dirk De Grave
    0

    @Claus: I've sent you an e-mail with details on how to retrieve passwords when users are only entering their email address instead of username.

     

    Cheers,

    /Dirk

  • Simon Probert 21 posts 45 karma points
    Sep 30, 2009 @ 08:23
    Simon Probert
    0

    Hi Dirk,

    Could you post that here as well? It would be quite handy for others :)

    Cheers

    SP

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 30, 2009 @ 08:34
    Dirk De Grave
    0

    Ok SImon, I'll see if I can digg up the code today.

     

    Cheers,

    /Dirk

  • Chief 24 posts 45 karma points
    Oct 01, 2009 @ 18:36
    Chief
    0

    Hi Dirk,

    Did u "digg up the code" ? - I need to figure it out as well :)

    Password retrieval from the members section (only email + password are used, no name or anything ;)

    /Chief

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 01, 2009 @ 19:11
    Dirk De Grave
    0

    Ha Chief

    My bad, sorry for late reply, was a bit forgotten about it! Ok, here's mail content I've sent to Claus a few weeks ago...

     

     

    I'm not sure whether you're actually using user controls (and macro) or using the asp.net controls directly from template, but I'll explain using the second method:

    Onto your template, drop (well, copy'n'paste) a asp.net PasswordRecovery control

     

    <asp:PasswordRecovery ID="UsernameRecovery" runat="server" MailDefinition-BodyFileName="RecoverUsername.txt">
            <UserNameTemplate>
                <fieldset>
                    <legend>Recover username</legend>
                    <p>
                        <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                        <asp:ValidationSummary ID="UsernameRecoveryValidationSummary" runat="server" DisplayMode="BulletList"
                            ValidationGroup="UsernameRecovery" />
                    </p>
                    <p>
                        <label id="UserNameLabel" for="UserName">
                            Email:</label>
                        <asp:TextBox ID="UserName" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                            ErrorMessage="*" ToolTip="User Name is required." ValidationGroup="UsernameRecovery">*</asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <asp:Button ID="SubmitButton" runat="server" CommandName="Submit" Text="Submit" ValidationGroup="UsernameRecovery" />
                    </p>
                </fieldset>
            </UserNameTemplate>
            <SuccessTemplate>Your username has been sent to you.</SuccessTemplate>
        </asp:PasswordRecovery>
    
    

     

    I'm pretty sure you know now how to use MailDefinition-BodyFileName property. 

    Key here is that we'll ask the user to enter his email address (mind the 'Email:' value for the 'UserNameLabel' label - don't change the names of the fields, they're reserved words!!), we'll subscribe to an event that is fired just before that info is sent to the membership provider (which will take care of the lookup of the password based on username) and when that event is fired, we'll substitute the value (e-mail address entered in 'UserName' textbox) with the username that corresponds to that email address (using the umbraco api). Membership provider is happy cause it'll receivee a username, we're happy because our users can still enter e-mail addresses.

    If I'm really talking rubbish or would like some more clarification, feel free to ask!

    Here's the code snippet for the events subscribing and handling.

    <script runat="server">
    protected void Page_Load(object sender, EventArgs e) {
        UsernameRecovery.VerifyingUser += new LoginCancelEventHandler(PasswordRecovery_VerifyingUser);
    }
    
    protected void PasswordRecovery_VerifyingUser(object sender, LoginCancelEventArgs e) {
        umbraco.cms.businesslogic.member.Member currentMember = Member.GetMemberFromEmail(UsernameRecovery.UserName);
    
        if (currentMember != null && currentMember.Id > 0) {
            UsernameRecovery.UserName = currentMember.LoginName;
        } else {
            e.Cancel = true;
        }
    }
    </script>
    Even better approach is to no longer use the Member API but use the Membership API for retrieving the member based on the email. I'll leave that as an exercise :p

    Cheers and good luck.

    /Dirk

     

  • Laura Holland 82 posts 103 karma points
    Oct 30, 2009 @ 21:53
    Laura Holland
    0

    Hmm.. I can't quite get this to work. The macro displays OK but it doesn't recognise a valid email address. I always get "We were unable to access your information. Please try again." even though the email address is a member's. No email is sent (I added the mailDefinition info):

    <MailDefinition BodyFileName="~/usercontrols/RecoverUsername.txt" From="[email protected]" Subject="Your account information"  />

    This is the Username.txt file:

    Your user name is: <%UserName%>
    Your password is: <%Password%>

    These fields are automatically filled in, right?

Please Sign in or register to post replies

Write your reply to:

Draft