On Account change, New user auth


I am facing an issue, where the user is not allowed to link an address to a moralis account, so each morails user will link to a single metamask account address.

I tried doing this by using the Moralis.onAccountsChanged, but it asks the user to sign request when changing the account, i am looking for a solution where app asks user he/she want to change the account and reauthenticate before poping up the metamask sign request.

Thanks in advance.

1 Like

Can you rephrase how you want it to work? I’m not sure I understood

I want that when user switch network, it should re authenticate user instead of linking the metamask account to the moralis user account.

Usually user doesn’t need to authenticate when he switches networks, you can add code to do authentication after a logout if you want instead of link.

Moralis ask for user sign when user try to change the account, i want to exclude the sign request part, i want to show a model either he/she want to change the account and then show user the sign request part and re authenticate.

I don’t think that is a default code when account is changed, I think that you can add there what functionality you want

This is my code, where user is loging out when he/she is changing the account, but it ask for the sign request on account change.

      const confirmed = confirm("Link this address to your account?");
      if (confirmed) {

Are you sure this is the code that asks for that sign? Can you add some logging messages?

@sudozee, Hi

I was trying to do the same thing, the signing message was annoying me on a UX level.
After having try a hundred things I ended up just updating the wallet address that was show and put another ‘Connect’ button anywhere the features were needed Moralis’ API.


1 Like