Copied to clipboard

Flag this post as spam?

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


  • Mathijs 27 posts 60 karma points
    Dec 09, 2010 @ 04:14
    Mathijs
    0

    Reset password after creating new user

    To be able to inform a user about it's newly created account, and provide the users it's password I thought of the following construction, which sets a new password which I afterwards send by e-mail. However.. one problem! The password never gets updated.. it stays the initally password set by the umbraco dialog.

    I use this code:

     Member.New += new Member.NewEventHandler(Member_AfterNew);

      void Member_AfterNew(Member sender, NewEventArgs e)

            { 

                String userName = sender.LoginName;

                String newPassword  = Membership.GeneratePassword(7,2);

                MembershipUser user = Membership.GetUser(userName);

                user.ChangePassword(user.ResetPassword(), newPassword);

     

      // ... send by email the newPassword

     

      }

    What could possibly go wrong?

     

  • Thomas Stock 40 posts 70 karma points
    Dec 10, 2010 @ 09:46
    Thomas Stock
    0

    That's strange, this is exactly what I do and it works here. (I guess you got this from the documentation I wrote)

    Do you still have this problem?

     

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Dec 10, 2010 @ 10:11
    Michael Latouche
    0

    Hi Mathijs,

    Did you check on the return value of the call to ResetPassword and ChangePassword? Maybe your declaration of the Membership Provider in the web.config does not allow password reset? You could check this by putting a test on the Membership.EnablePasswordReset property. More info about this can be found in the example on the Microsoft site: http://msdn.microsoft.com/en-us/library/d94bdzz2.aspx

    Cheers,

    Michael.

     

  • Mathijs 27 posts 60 karma points
    Dec 13, 2010 @ 01:46
    Mathijs
    0

    Thanks for you replies guys. Problem remains. My web config look like this:

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

    So the PasswordReset is enabled.

    I did the following trials to change codes behaviour:

    • Bound Member_AfterNew to Member.AfterSave method to see what happens... ..nothing happened
    • Manually passed userName to getUser method. (Method does throws exception when user does not exist)


     

Please Sign in or register to post replies

Write your reply to:

Draft