I'm faced with a challenge to get a user to reset their password. I have a Post Copy script that updates the users email address, profile id and then sets the users password to a random string. This is to ensure that they are forced to reset their passwords (by clicking the forgot password link).

The steps are as follows:

  1. The post copy class runs after a sandbox is created
  2. The user's email address and profile is changed.
  3. The user must confirm the email address change.
  4. When the user tries to log in they cannot and are forced to click the forgot password link.
  5. After doing this and entering their username an email is with a link to reset their password
  6. The user clicks the link and gets directed to answer a security question.
  7. When entered correctly the page is redirected to the login page for the user to enter username and password.
  8. An email is received saying that you cannot reset your password because it has been changed in the past 24 hours...

The issue comes in where I have to wait 24 hours to change the password... I know there is a password policy that I can change (Require a minimum 1 day password lifetime) but this setting needs to be kept on for security purposes.

Does anyone perhaps know of a work around? I did try using system.resetPassword, but can only be done provided the user has accepted their email address has changed.

  • You're basically in a tough position for the reasons you mentioned (email needs to be confirmed, can't remove the 1 day minimum). A better question may be "why" you have to force them to change their password immediately. Can it be done through training (tell them to do it so you don't have to set their password) or is it ok if it's done a certain amount of time afterwards through a scheduled job or whenever their password naturally expires? – Kris Goncalves Apr 20 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.