Validation hooks for ForgotPassword

Hey all,

I was wondering how I can do a custom validation check with the ForgotPassword snippet. I wrote a script that imports and creates thousands of user accounts into the CMS. Some of the accounts do not have an email address so I set a temp email address to be saved in the email field as {account_number}@noemail.com.

What I’m trying to achieve is that when the user tries to log into their portal and try to reset their password, I would run a validation check to see if their email was set to “@noemail.com” and if true, make a request to the user to submit their email address. This email address will be sent to the client’s customer service team to verify the customer’s email request update and they will set the new email address via the backend and email the customer their password.

Is it possible to add custom hooks to the ForgotPassword snippet? Or will I have to write a custom snippet to achieve this?

https://docs.modx.com/3.x/en/extending-modx/plugins/system-events/onmanagerlogin

https://docs.modx.com/current/en/extending-modx/plugins/system-events/onweblogin

This series of articles might be useful to you.

The ForgotPassword snippets runs prehooks (property preHooks) before the E-Mail is sent. So maybe you can use a prehook snippet to check the user and do a redirect, if the email-address matches @noemail.com.