Web3auth mixes into other firebase auth in same browser - custom auth

Hi, I am using firebase (Email/Password) custom auth. Currently if a user signs up, for example with test1@gmail.com it will be via this firebase auth backend and using the jwt token provided by firebase auth, it will create a web3auth account associated with this user. So test1@gmail.com will be associated with 0xAb....xye4 address for example (tab 1 of browser A). Now if a new tab is opened in the same browser, and a new user is created using this process, everything goes well and there will be another email associated with a new address, for example test2@gmail.com with 0xf5....sf45 (tab 2 of browser A).

The issue is however, when i go back to tab 1, I noticed the firebase auth details of the first user remains as usual (test1@gmail.com), but the web3auth details has changed to user's 2 details (0xf5....sf45), and indeed if I run web3auth's getUserInfo(), it shows the details of user 2 (test2@gmail.com).

In short,

When the browser has 1 user logged in, the account on it shows the expected details:
firebase auth 1 + web3auth 1 (tab 1)

When the browser has multiple users logged in the same browser, the account mixes the older logged in accounts with the latest logged in account's web3auth details, so something like:

firebase auth 1 + web3auth 4 (tab 1)
firebase auth 2 + web3auth 4 (tab 2)
firebase auth 3 + web3auth 4 (tab 3)
firebase auth 4 + web3auth 4 (tab 4)

What I expect if browser has multiple users logged in:
firebase auth 1 + web3auth 1 (tab 1)
firebase auth 2 + web3auth 2 (tab 2)
firebase auth 3 + web3auth 3 (tab 3)
firebase auth 4 + web3auth 4 (tab 4)

Note that this only occurs when I change chain (ie reload web3auth instance)



Originally posted by: junhuang-ho

Check the discussion at: https://github.com/orgs/Web3Auth/discussions/392

Web3auth sessions are not tab scoped by default, they are browser scoped, To solve this problem you can pass storageKey param to session in web3auth constructor. That will make web3auth session scoped to tab.



Originally posted by: himanshuchawla009