Detect wallet disconnect

How would I detect in my web app that a user has disconnected their wallet? I am using vanilla js and this function to connect.

        user = await Moralis
            .authenticate({signingMessage: "Log in"})
            .then(function (user) {
                console.log("logged in user:", user);
                console.log(user.get("ethAddress"));
                userAddress = user.get("ethAddress");
                currentUserWallet = user.get("ethAddress");
                $("#app").fadeIn(500);
            })
            .catch(function (error) {
                console.log(error);
            });

If there is no wallet data under Moralis.User.current() then there is no active user.

I am still able to get the current user’s wallet address by calling…

function showUser(){
    let user = Moralis
    .User
    .current();
    console.log(user.get("ethAddress"));
}```

even after I disconnected using metamask's disconnect.

I have been able to detect walletconnect connection disconnecting by using this…

Moralis.provider.on("disconnect", (error, payload) => {
  console.log('Disconnected');})

but,this does not work for Metamask. Any ideas on how to get it to work?

Moralis.User.current() will return null if the logout is successful.