Moralis.User.requestPasswordReset

Hello, i try to use that function Moralis.User.requestPasswordReset and i get the error:

Error: 1 An appName, publicServerURL, and emailAdapter are required for password reset and email verification functionality.

In my Morails profile i have also already save my Sendgrid API key and my email.

From where does this error come and how can i slove it?

Please share your code to review if you are missing some parameters or follow this guide;

Carlos Z

i did search for simular problems but have not find infos, i can show you my code it is very simple and i wonder where the problem comes from:

app.post('/resetpassword', async (req, res) =>
{
	  //---
	  let username = req.body.username;
	  //---	  
	  Moralis.User.requestPasswordReset(username)
		.then(() => {
		  // Password reset request was sent successfully
		  console.log("Password reset request was sent successfully");
		}).catch((error) => {
		   // Show the error message somewhere
		   console.log("Error: " + error.code + " " + error.message);
		});
});

that above is my node.js code, the username is a email adress, i have take the code for sending password reset from Morails documentation, i am wondering now if the function want to have more parameters, if yes it would be written in the documentation, so maybe its something other. I have also create a API Key for Sendgrid and i have save that API Key in my Moralis profile.

If you have a idea let me know, thanks.

you should check that let username = req.body.username; is sent has string value, keep in mind that requestPasswordReset does work only with string emails.

https://docs.moralis.io/moralis-sdk/users#reset-password

Carlos Z

When i write the email directly as a string then i get now the following error:>

(node:2820) UnhandledPromiseRejectionWarning: ReferenceError: alert is not defined
at C:\test\index.js:216:5
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2820) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)

i dont know if he have send the email or not, i dont see a email has come.

Do you know maybe how i can at least make sure that the error does not come from Sendgrid account? Is there a way to make test email send with Sendgrid? I normaly have not use Sendgrid before i dont know much about it, i usual have use just easy PHP function sendmail()

I just wonder why it dont want to work, the user registration and login have work very easy but this reset password part makes problems

Might be that you are not creating the alert in case it fails. Check the documentation, try to do apply the same syntax for your code and see how it goes.

Moralis.User.requestPasswordReset("[email protected]")
.then(() => {
  // Password reset request was sent successfully
}).catch((error) => {
  // Show the error message somewhere
  alert("Error: " + error.code + " " + error.message);
});

Carlos Z

1 Like

Hi @thecil, I hope you are doing great!

I am facing the same issue, trying to use the resetpassword in react. My code example

i dont know, its just strange, i have using the example from documentation, you see above my code is the same like in documentation. ok i see you also have no idea, i guess it works in your test, so i dont know then why it dont do the work in my test

Hi @LearningMoralisCodei,

We have fixed the password Reset issue. You should be able to send them to your Moralis users. Please try again and see.

Also, we have updated the docs with the new settings to help you navigate better. Do check it out!
https://docs.moralis.io/sending-email

https://docs.moralis.io/users/reset-password

Thank you for pointing out these issues. All your feedback goes a long way ! Thank you ! :star_struck: