I have an authentication question

I uploaded a gif but it is not displayed, Let’s go in parts, first the login, then there is another error due to email authentication that in const user = await Moralis.User.current(); When I log in by email, the user does not recognize me, function login metamask

const Login = async () => {

    setStateCircularProgress(true);

    try {

      const provider = "metamask";

      await enableWeb3({ provider: provider});

      console.log("account", account)

      console.log("chainId", chainId)

      const { message } = await Moralis.Cloud.run("requestMessage", {

        address:  account,

        chain:  parseInt(chainID.testNet),  

        network: "evm",

      });

      console.log("chainIdMoralis", message)

      console.log("message", message)

      console.log("chainId", chainId)

      console.log("message", message)

      if (!account) {

        throw new Error(

          "Connecting to chain failed, as no connected account was found"

        );

      }

      if (!chainId) {

        throw new Error(

          "Connecting to chain failed, as no connected chain was found"

        );

      }

      setValuesAlertFunc(true, "Login success", "success");

     

      if (!state.authenticated) {

        if (chainId != chainID.testNet ) {

          await switchNetworkPolygon();

        }

        await Moralis.authenticate({

          signingMessage: message,

        }).then(async (user: any) => {

          const userMarketType = user!.get("loginType");

          setValuesAlertFunc(true, "Welcome to Koolinart", "success");

          console.log('user', user)

          dispatch({

            type: "USER_AUTHENTICATED",

            payload: true,

          });

          dispatch({

            type: "GET_LOGIN_TYPE",

            payload: userMarketType,

          });

          dispatch({

            type: "USER_RENDER",

            payload: user,

          });

        });

        const ethAddress = state.userRender.attributes?.ethAddress

          ? state.userRender.attributes.ethAddress

          : "";

        await fetchTokenBalance(ethAddress);

      }

    } catch (e) {

      const errorMessage = JSON.stringify(e);

      const errorObjeto = JSON.parse(errorMessage);

      setValuesAlertFunc(true, errorObjeto.message, "error");

      console.log("error", e);

      setStateCircularProgress(false);

    }

  };

I notice that the login works, reading the forum it worked, changing the import import Moralis from "moralis-v1"; to import { Moralis } from "moralis-v1";

but I have to give it 2 times to authenticate the first time it gives an error, why does this happen?, and i also notice that the string id is 80001, when i am in mumbai

const LoginMail = async (values: any) => {

    setStateCircularProgress(true);

    if (!state.authenticated) {

      await Moralis.User.logIn(values.username, values.password )

        .then(async function (user: any) {

          const userMarketType = user.get("loginType");

          dispatch({

            type: "USER_AUTHENTICATED",

            payload: true,

          });

          dispatch({

            type: "GET_LOGIN_TYPE",

            payload: userMarketType,

          });

          dispatch({

            type: "USER_RENDER",

            payload: user,

          });

          setValuesAlertFunc(true, "Welcome to Koolinart", "success");

        })

        .catch(function (error: any) {

          // setValuesAlertFunc(true, " Invalid username/password.", "error");

          const errorMessage = JSON.stringify(error);

          const errorObjeto = JSON.parse(errorMessage);

          setValuesAlertFunc(true, errorObjeto.message, "error");

              setStateCircularProgress(false);

          console.log("🚀 error de login", error);

        });

      const ethAddress = state.userRender.attributes?.ethAddress

        ? state.userRender.attributes.ethAddress

        : "";

      await fetchTokenBalance(ethAddress);

      setStateCircularProgress(false);

    }

  };

Where is what error that happens first time? Try to add logging at every step to see what happens.

What chain id you were expecting for mumbai?

if you are right, sorry 80001(0x13881) I expected 0x13881 but it is equal to 80001, now in the metamask function which is the function called login, because I have to give it 2 times to authenticate, where the first time I click to login I receive this error:
2023-04-24_02h40_07

and the second time I click to login, if it authenticates me

It was an invalid address?

wow,i just fixed the bug, i explain: how i execute the functions in a context provider i was declaring the variable const { account, chainId } = Moralis; globally but not in the function, by introducing this constant in the function I corrected the error of double-clicking it to recognize it, the light bulb went on, hahaha, now we are going for the second login error, which is that when I do login via email, the user does not recognize me in moralis here: const user = await Moralis.User.current();

2023-04-24_02h59_09

Why when you start with metamask are these data filled and not by mail? should i fill in this information? Or does not it matter? And why doesn’t the user recognize me in the aforementioned?

that moralisEth info is specific to wallet address authentication only