Hello, I have a metamask authentication function with moralis, and when connecting the function to the self-hosted server it returns an error: error: Moralis auth failed, invalid data {ācodeā:101,āstackā:āError: Moralis auth failed , invalid data\n at C:\Users\david\Documents\Programming\react\Koolinart\backend\src\auth\MoralisEthAdapter.ts:32:13\n at runMicrotasks (< anonymous>)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at async Promise.all (index 0)ā} I attached the authentication function, I have more questions about the authenticator, which I have not met Sure, but Iāll go in parts. thank you.
The first function is via metamask, the second function is via email, the authentication function via email works fine, but the metamask one doesnāt, the question in the email one is how to authenticate the message data or some data that was required the authdata field in moralis. because when I authenticate myself, the authenticated user does not recognize me. I mean, the email authentication function works but halfway
const Login = async () => {
setStateCircularProgress(true);
const provider = "metamask";
try {
// () => setValuesAlertFunc(true, "Login success", "success");
if (!state.authenticated) {
await Moralis.enableWeb3({ provider });
const chainId = Moralis.chainId;
if (chainId != "0x13881") {
await switchNetworkPolygon();
}
await authenticate({
signingMessage: "Welcome to Koolinart",
throwOnError: true,
}).then(async function (user) {
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);
}
};
const LoginMail = async (values: any) => {
setStateCircularProgress(true);
if (!state.authenticated) {
await Moralis.User.logIn(values.username, values.password)
.then(async function (user) {
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) {
// 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);
}
};
When reading the log, I notice that they say that this will be disabled in the future, so the question would be how would I do it now?