try something like this
init = async () => {
window.web3 = await Moralis.Web3.enable();
initUser();
}
initUser = async () => {
if (await Moralis.User.current()) {
//do stuff such as dispaly eth address etc
}
}
login = async () => {
try {
await Moralis.Web3.authenticate();
initUser();
}catch (error) {
alert(error)
}
}
logout = async () => {
await Moralis.User.logOut();
initUser();
}
init()
connectButton.onclick = login
this is a very basic and simple implementation just to give you an idea youlll need go work on this. but using the User.current you can presisit the sessiom on page load i believe.