Realm Web SDK auth password reset function does not work

I use Realm’s web SDK.

I can set up Resetpassword and choose two different methods.

Password Reset Method: ‘Run a password reset function’ or 'Send a password reset email.

I chose ‘Run a password reset function’ and wrote a function on Realm and setup ‘sendResetFunc’ when users users ask.

I check ‘runFunction: true’ (something equivalent) on the review/deploy so all things look perfect.
However, if I run app.emailPasswordAuth.resetPassword(), it does not run the function I wrote and specified on Realm UI but MongoDB sends the reset PW email, which should be sent if I tick ‘Send a password reset email’ on the UI.

My setting on Realm ‘Run a password reset function’ does not work properly.

This looks like a bug. Do I need to still use Stitch?

1 Like

If you have defined a reset function, you need to call callResetPasswordFunction(). See also Class: EmailPasswordAuth


Thank you for your reply, Kenneth.

But I’m confused.

I am setting up ‘Send a password reset email’ to the users.
emailPasswordAuth.callResetPasswordFunction(email, password, args) is a function to RESET the password but not a method to SEND AN EMAIL THAT HAS A LINK TO REST PW.

As I explained, I need to send an email that had token/tokenId to reset the password and the token/id should be passed to the arguments of the function I wrote according to the Realm.

I attached an image below. What I mean is that I ticked ‘run reset email func’ which I linked to SendGrid but it does not run. Instaead, MongoDB sends ‘reset PW email’ which is supposed to happen when I tick the another check box called ‘Send a password reset email’.

1 Like

If anyone else stumbles on this because you’ve hit the same issue, Kenneth’s response is the correct one. Unfortunately, the docs make this very confusing by stating that callResetPasswordFunction “Resets the password of an email identity using the password reset function set up in the application.” Since the goal is to send the password reset email, it would make far more sense for sendPasswordResetEmail determine if you have a custom function defined or if you want to use the stock Realm email. This is not very intuitive.

If you read these docs, you’ll see that they actually list sending an email as an example:

  • Send custom password reset emails from a specific domain with a particular template using an external service.

Another element making callResetPasswordFunction confusing is that it accepts and actually forces you to send a minimum 6 character password in as a parameter when that really isn’t the action we’re trying to take. Sending in dummy data gets around this issue. Though again, sendPasswordResetEmail knowing what to do on the Realm side would make far more sense from an API perspective.

1 Like

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