I was testing my app with a few testers where most of them successfully logged in with MetaMask.
But a Windows user failed the signup: He got MetaMask popped up, but found unable to click “Sign”. I noticed there was nothing on Id
section.
This is the code I used to authenticate users. It worked for most of my test users, but it failed the authentication only for the Windows guy. Could anybody know what it caused?
async function login() {
let user = Moralis.User.current();
if (!user) {
user = await Moralis.authenticate({
signingMessage: "MetaMask Signup / Login",
}).then(function (user) {
bubble_fn_ethAddress(user.get("ethAddress"));
console.log("logged in user:", user);
console.log(user.get("ethAddress"));
}).catch(function (error) {
console.log(error);
});
}
}
login();
// Save new Metamask account to Moralis db
Moralis.onAccountChanged( async (account) => {
const query = new Moralis.Query("_User")
query.find().then((data) => {
async function load() {
const queryUser = data[0].get("accounts");
console.log("queryUser:", queryUser)
let web3 = await Moralis.enableWeb3();
const address = (await web3.listAccounts())[0].toLowerCase();
console.log("currentAddress:", address);
const containsEth = queryUser.includes(address);
console.log("includes", containsEth)
if(!containsEth) {
bubble_fn_onAccountChanged(JSON.stringify(account));
console.log("new account detected2")
}
}
load();
});
})