[react-moralis] custom Hooks Password Reset issue - Moralis.User.requestPasswordReset

Did you initialise your moralis provider on the app ?

Like this? –

<MoralisProvider appId="xxxxxxxx" serverUrl="xxxxxxxx">
    <App />
  </MoralisProvider>,
1 Like

Yes:

import React from "react";
import ReactDOM from "react-dom";
import { MoralisProvider } from "react-moralis";
import { ChakraProvider, extendTheme } from "@chakra-ui/react";

import App from "./App";

const theme = extendTheme({
  config: {
    initialColorMode: "dark",
  },
});

const appId = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const serverUrl = "https://XXXXXXX.moralis.io:2053/server";

ReactDOM.render(
  <React.StrictMode>
    <MoralisProvider appId={appId} serverUrl={serverUrl}>
      <ChakraProvider theme={theme}>
        <App />
      </ChakraProvider>
    </MoralisProvider>
  </React.StrictMode>,
  document.getElementById("root")
);

Ah I see, since you are not using the inbuilt hook to call Moralis.User.requestPasswordReset , it is not able to retrieve the initialised values. I will get back to you with the right implementation for non hook functions.

Do give me some time.

1 Like

@malik I ran right into that too. The problem seems to be the React version of import { useMoralis } from "react-moralis"; and the const { user } = useMoralis() it provides does not have a static requestPasswordReset(email) function to match the non-ReactJS documentation.

I’m new to all this ReactJS circus so my jargon’s a bit weak. But might I suggest that due to the transitory nature of user an independent ‘hook’(?) would be better: const {requestPasswordReset } = useMoralis(). Because when we need it we obviously don’t have a user yet.

And I’m guessing at this point I’m not saying anything y’all haven’t figured out long ago. I’m catching up. Give me a minute. I’m just posting this here so I get pinged when the new requestPasswordReset uh…‘hook’ is announced. Y’all are awesome, keep up the good work!

image

1 Like

Any news regarding the correct syntax for calling password reset in react? @malik
I am getting this error: Error:1 An appName, publicServerURL, and emailAdapter are required for password reset and email verification functionality. See my code here:

PasswordResetComponent
import React, { useState } from "react";
import { Button, Stack, Input } from "@chakra-ui/react";
import { Moralis } from "moralis";
const ResetPassword = () => {
  const [email, setEmail] = useState();

  return (
    <Stack spacing={3}>
      <Input
        isRequired
        placeholder="E-Mail"
        value={email}
        onChange={(event) => setEmail(event.target.value)}
      />
      <Button
        onClick={() => {
          Moralis.User.requestPasswordReset(email)
            .then(() => {
              alert("Password request successfull, please check your Email!");
            })
            .catch((error) => {
              alert("Error:" + error.code + " " + error.message);
            });
        }}
      >
        Request Password Reset
      </Button>
    </Stack>
  );
};

export default ResetPassword;

Hi @Thomas,

Please try this way –

import React, { useState } from "react";
import { Button, Stack, Input } from "@chakra-ui/react";
import { useMoralis } from 'react-moralis';
const ResetPassword = () => {
  const [email, setEmail] = useState();
  const { Moralis } = useMoralis();


  return (
    <Stack spacing={3}>
      <Input
        isRequired
        placeholder="E-Mail"
        value={email}
        onChange={(event) => setEmail(event.target.value)}
      />
      <Button
        onClick={() => {
          Moralis.user.requestPasswordReset(email)
            .then(() => {
              alert("Password request successfull, please check your Email!");
            })
            .catch((error) => {
              alert("Error:" + error.code + " " + error.message);
            });
        }}
      >
        Request Password Reset
      </Button>
    </Stack>
  );
};

export default ResetPassword;

We are using the hook to import the global Moralis Object.

Let me know if this works

Thanks.

1 Like

Unfortunately, still getting this error:

Does it work for you?

Unfortunately, I’m also getting a similar error. Will check with the core team.

1 Like

This is indeed an error from our system and the core devs are working to solve this. Mostly by next week it should be solved. :slight_smile:

Thank you for pointing these issues out. Truly helps us in maintaining a world class product.

Cheers. :tada:

1 Like

Have they solve this issue yet?

1 Like

Haven’t heard anything yet. Hope it is coming soon.

I’m getting the same error, but using await Moralis.User.requestEmailVerification();

1 Like

@malik do you maybe have any insight in when this will be fixed, or is there a “hack”? It would be so awesome to have this available with react as well. Considering using this for production :thinking:

I have the same problem with 0.0.30

@malik, @ivan, Wanted to check in with you guys to see if this is going to be added soon? or is there a workaround?

Will check with the team right away!

Two points that I Noted –

  1. No email is being sent to the email address provided.
  2. The send grid api authentication is done correctly on the Email configuration tab.

And other details that I’m missing out?

The error message I posted above may be of interest. But yes, that is it. :slight_smile: Thank you

This is on our to do list and will update you when it’s fixed.

The devs are extremely busy the past few weeks. We need all the support from you devs to pull off the dream of Moralis successfully. :raised_hands:

Thank you for your patience. and most importantly, Happy BUIDLing! :man_mechanic:

1 Like

Thank you,
I really appreciate all the hard work you put in for us. I did dive into other, comparable, services like Moralis in the past weeks and can say without doubt that Moralis is by far the best I could find so far!
Keep it up! :raised_hands:

2 Likes

Hi @Thomas @Easa @infinity,

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: