We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25308
    • 46 Posts
    Hi all,

    I know that the Login package for MODx Revo has a forgot password function. When you use this it sends an email to the user with a new password that is a random string and a link to activate it.

    I would like to give my Users the ability to determine what their new password would be. I’ve been looking around with little luck. The password fields didn’t incorporate into the update profile form either,...

    Any thoughts oh mighty ones?
      • 3749
      • 24,544 Posts
      I don’t feel very mighty today, but the Login package contains a "ChangePassword" snippet. You might be able to redirect the user from the landing page for forgot password to a page with that snippet on it (or provide a link to that page). If not, it would be a good feature request because leaving the user with a password that has been sent via email is probably not a good idea.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 25308
        • 46 Posts
        Quote from: BobRay at Aug 16, 2011, 06:26 PM

        I don’t feel very mighty today, but the Login package contains a "ChangePassword" snippet. You might be able to redirect the user from the landing page for forgot password to a page with that snippet on it (or provide a link to that page). If not, it would be a good feature request because leaving the user with a password that has been sent via email is probably not a good idea.


        Bob,... knowledge is power so you’re always mighty. ; )

        I’m currently using the "Change Password" snippet. It seems to only be the resource page that has the message informing you that your password has now been changed after you click the new password activation link in the email. I completely agree that leaving the password as the one in the email is a bad idea. Besides security reasons,...random string passwords are hard to remember. LOL

        I guess I’ll have to make a feature request. Thanks for the feedback.
          • 3749
          • 24,544 Posts
          Can’t you just put something like this on the landing page?

          <p>Your temporary password is insecure, please change it <a href="[[~##]]"> here</a>.</p>
          

          where ## is the ID of the page with the change password snippet and the change password form?

          Or, you could put a snippet on the landing page that just forwards them to the change password page.

          <?php
          $modx->sendRedirect($modx->makeUrl(##) );
          

          where ## is, again, the ID of the change password page (which would contain the message about the temp. password being insecure).




            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 25308
            • 46 Posts
            Bob I will definitely put that note in the forgot password email and on the activation page. That’s a great suggestion.

            I ended up finding the solution after changing my search string on the forum at

            http://modxcms.com/forums/index.php?topic=53480.0

            It seems that there was more to the Change Password snippet that I thought. I didn’t understand that you could call it and make a form to change the password.

            Lyubomir posted this and so far its worked with all of my tests...

            [[!ChangePassword? &reloadOnSuccess=`0` &successMessage=`[[!%login.change_password? &namespace=`login` &topic=`changepassword`]] - [[!%login.profile_updated? &namespace=`login` &topic=`updateprofile`]]`]]
            
            <div class="change-password">
             <div style="color:#66CC00">[[+logcp.successMessage]] </div>
            
            <br /> 
                <form class="form" action="[[~[[*id]]]]" method="post">
                    <input type="hidden" name="nospam:blank" value="" />
            
             
                    <label for="password_old">[[!%login.password_old? &namespace=`login` &topic=`changepassword`]]:
                        <span class="error">[[+logcp.error.password_old]]</span>
                    </label>
                    <input type="password" name="password_old" id="password_old" value="[[+logcp.password_old]]" />
              <br />
                    <label for="password_new">[[!%login.password_new? &namespace=`login` &topic=`changepassword`]]:
                        <span class="error">[[+logcp.error.password_new]]</span>
                    </label>
                    <input type="password" name="password_new" id="password_new" value="[[+logcp.password_new]]" />
              <br />
                    <label for="password_new_confirm">[[!%login.password_new_confirm? &namespace=`login` &topic=`changepassword`]]:
                        <span class="error">[[+logcp.error.password_new_confirm]]</span>
                    </label>
                    <input type="password" name="password_new_confirm" id="password_new_confirm" value="[[+logcp.password_new_confirm]]" />
              <br />
             
             
                    <br class="clear" />
             
                    <div class="form-buttons">
                        <input type="submit" name="logcp-submit" value="[[!%login.change_password]]" />
                    </div>
                </form>
            </div> 


            Per your suggestion Bob I have now have a login system that makes more sense. Thanks.
              • 25308
              • 46 Posts
              Quote from: BobRay at Aug 17, 2011, 05:34 PM

              Can’t you just put something like this on the landing page?

              <p>Your temporary password is insecure, please change it <a href="[[~##]]"> here</a>.</p>
              

              where ## is the ID of the page with the change password snippet and the change password form?

              Or, you could put a snippet on the landing page that just forwards them to the change password page.

              <?php
              $modx->sendRedirect($modx->makeUrl(##) );
              

              where ## is, again, the ID of the change password page (which would contain the message about the temp. password being insecure).


              Do you have any suggestions for my other question about login redirect not working on IE browser?

              http://modxcms.com/forums/index.php/topic,67817.0.html

              Sad to say I don’t understand how to use the success message instead of the redirect. Sigh,... THanks,
                • 3749
                • 24,544 Posts
                Sorry, the only thing that comes to mind is IE conditional comments in the template, but that’s pretty unlikely to cause your problem.

                I’m guessing, but I think to use the success message, you just take out the redirect property, set the success message property and redirect the form to the current page. (action="[[~id]]"). You need to include a placeholder for the success message on that page.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 25308
                  • 46 Posts
                  Quote from: BobRay at Aug 18, 2011, 04:56 PM

                  Sorry, the only thing that comes to mind is EI conditional comments in the template, but that’s pretty unlikely to cause your problem.

                  I’m guessing, but I think to use the success message, you just take out the redirect property, set the success message property and redirect the form to the current page. (action="[[~id]]"). You need to include a placeholder for the success message on that page.

                  Thanks again Bob. That sounds like the solution I’m looking for. I’m didn’t understand the documentation for the success message. I don’t know if I can set anything as the placeholder for the success message, such as [[successmessage]] or if it has to be in a specific format. I guess some experimentation is in order.

                  Thanks again for your help Bob. I appreciate it. ; )