Sending a custom email template for reset password

When using realm for authentication, is it possible to send a custom email when calling the reset password function? Currently, when setting a resetFunctionName, it does not run this function (in here we send our own reset email template).

We have it set up the same way for sending the signup confirmation - which works just fine. Only when trying to customize the password reset experience, we are not able to do so.

Hi @Martin_Kayser,

So according to what you are saying usin a confirmation function which sends a confirmation email does work, while using similar logic for resetPassword does not?

Can you share your application link? How do you trigger the password reset? Which sdk?

Best
Pavel

We currently have it set up as follows:

  • Authentication > Email/Password > Password Reset: Run a Password Reset Function
  • Custom Function: RunResetPasswordNotificationEmail({ username, password, token, tokenId }), returns “pending”
    – First thing here: why do we need to pass a password that is never used? As the user gets an email after this step, and with the authenticated link they will reset their password using resetPassword()
  • Client side

await this.$client.emailPasswordAuth.callResetPasswordFunction(this.email, “RandomPass”);

where this.email is the same as username.

Calling the function results in the following error:

UserNotFound Error (Authentication)
Error:
user not found

The following works, but it does not allow us to send a custom templated email:

await this.$client.emailPasswordAuth.sendResetPasswordEmail(this.email);

Using JavaScript:

“realm-web”: “^0.6.0”,

Any ideas what could be going wrong?

Thanks,
Martin

Hey Martin,

Can you try updating your realm-web version to 10.0 - the version you are using was a beta version and the issue may have been fixed in a later version.

The syntax in the stable version has also changed to callResetPasswordFunction

https://docs.mongodb.com/realm/web/manage-email-password-users/#call-a-password-reset-function

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.