Second Metamask account does not work for Moralis login

Hi,
I am using Metamask with my first account and I logged in successfully using:
user = await Moralis.Web3.authenticate();
But, when I switch to my second Metamask account I get the following error although there is only one line in the ā€œUserā€ database which is my first Metamask account. With my second one I get the following error:
moralis.js:21595 POST https://luoljbifa2qa.moralis.io:2053/server/users 400 (Bad Request)
main.js:111 Error: A duplicate value for a field with unique values was provided
at handleError (moralis.js:21728)
Actually I only provide a different username with the second Metamask address, but this does not work. Did you see this error before? Is the database somehow corrupted? I can also delete all automatically created lines in the ā€œUserā€ database (excluding the first Metamask account) but the issue does not disappear.

1 Like

Hey @CryptoTabaluga, did you disconnect the first account before switching from the 2nd one? you could also try deleing the entire user data, to start from the beginning, might be useful to check your codeā€¦

Carlos Z

Hi ! Yes, I disconnected the first account and then I reload the whole page and then I connect the new account, but I still get the errorā€¦ the only thing I did not try out is deleting the whole ā€œUserā€ database, because I might end up with deleting the server and re-installing it, because I am not able to login in with any account, but I think this might be what I need to doā€¦hmm

Now it is really badā€¦ I deleted all rows within ā€œUserā€ and I get the same error for all my accounts now including my first Metamask account - although the User class is emptyā€¦ not able to log in anymore with no accountā€¦ Do I have to install everything again ? Because I implemented all the classes and the event listener plugins etcā€¦

@thecil I found the answer in another postā€¦ It is quite a weird issueā€¦

1 Like

Amazing, although moralis is working very nice, is still on constant develop, so itā€™s normal to find bugs with weird solutions.

Keep working!
Carlos Z