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:
- The post copy class runs after a sandbox is created
- The user's email address and profile is changed.
- The user must confirm the email address change.
- When the user tries to log in they cannot and are forced to click the forgot password link.
- After doing this and entering their username an email is with a link to reset their password
- The user clicks the link and gets directed to answer a security question.
- When entered correctly the page is redirected to the login page for the user to enter username and password.
- 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.