Cannot save password reset function

I want to use a custom password reset function to be invoked by my Swift client via sendResetPasswordEmail.

In the MongoDB Realm Authentication Providers page I selected Automatically confirm users for User Confirmation Method and Run a pssword reset function for Password reset method.

After selecting + New Function in order to provide a body for the resetFunction and entering the code below:

  exports = ({ token, tokenId, username, password }) => {
    // will reset the password
    return { status: 'success' };
  };

I get the following error when I press the Save button:

invalid value for resetFunctionId

Could you please help me with this issue?

Hey Alfredo -

Did you name your resetFunction with a name? This error usually shows up when you have left the function name blank/removed it:

If that’s not the case, can you attach some screenshots and your stack trace from the console so we can take a closer look?

1 Like

Hi Sumedha,

Thanks for your reply.

I tried to provide a body for resetFunc and also to another function that I named, but I got the same error for both.

Please find the link to my app below.

https://realm.mongodb.com/groups/5efa3289244bdc4f6d5c3028/apps/5f661c0474ea39958d2b81e2/dashboard

Thanks.

Alfredo da Silva

Can you also screenshot your current config and the stack trace when that error appears? Unfortunately, I don’t get too much information about the error from just looking at your app.

Hi Sumedha,

I’m not sure what you mean by current config, and there is no stack trace, just an error on the Authentication Providers page: “Invalid value for resetFunction”.

Below is the link where you can find Authentication Providers page screen shots:

https://drive.google.com/drive/folders/1OvdWorhpdu3qLadaL0bCeaYtAZ9Ea3S8?usp=sharing

Thanks.

Alfredo

It seems like you’re hitting “new function” but you already have “resetFunction” defined. For now, you can get around this be hitting “existing function” and using the resetFunction or a new function you have defined.

We will work on making that error message a bit more clearer for users - hope this helps!

Hi Sumedha,

It is not clear to me yet how I can edit the body of the resetFunction, or any other function that I create to reset the user’s password and save these changes, without getting the error I mentioned earlier.

Could you please elaborate?

Thanks.

Alfredo

You can go here in the ‘Functions’ tab to edit the already created function. https://realm.mongodb.com/groups/5efa3289244bdc4f6d5c3028/apps/5f661c0474ea39958d2b81e2/functions/5f661ea074ea39958d2ca572

Hi Sumedha,

I’ve just got it to work.

Thank you so much for your help.

Alfredo

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