I have a pretty standard code used by logging in via MetaMask, something similar to this:
const connectWallet = async () => {
const provider = new ethers.providers.Web3Provider(window.ethereum)
await provider.send("eth_requestAccounts", [])
//.......
//make the text on the LogIn button "Loged In"
}
Everything works fine except the fact that when MetaMask gets auto-locked by the password every one or several hours. When it does, the other stuff such as buttons that are dependent on the fact that the user is logged in, will change their state as if a user wasn't logged in.
I'll then open MetaMask, enter the password thus unlocking it, and everything will begin to work properly again.
What's the matter? Is this the intended behaviour? If not, how to fix it?