3box / 3box-js

3Box JavaScript SDK: User identities, storage, messaging
MIT License
207 stars 65 forks source link

OrbitDB error when logging in with a different account #905

Open e18r opened 3 years ago

e18r commented 3 years ago

Bug description

When a user logs out, refreshes the page, and then tries to log in with a different Ethereum account, an error is thrown from OrbitDB's ipfs-log repo:

Uncaught (in promise) Error: Could not append entry, key "did:3:bafyreiboe6bsrc6xxqxi5urmfyaw6weevhfkotn3n23dpnkbalz2donana" is not allowed to write to the log at Log.append (log.js:308) at async FeedStore.addOperation (Store.js:517) at async run (index.js:158)

Note 1: The key in question (did:3:bafy...nana in this example) corresponds to the previous 3box account that is supposed to have logged out. Note 2: I added links to the actual lines of code where the error is thrown. The line numbers don't match exactly. Note 3: Clearing localStorage doesn't seem to solve this issue.

To Reproduce

  1. Run the example app from this repo: a. git clone https://github.com/3box/3box-js b. cd 3box-js/example c. npm ci d. npm run example:start
  2. On a browser with Metamask, head to http://localhost:30000. Unlock your MetaMask account. Press [F12] to open the developer console.
  3. Click on the "Auth 3box" button. Complete the login process. Wait until you are logged in.
  4. Click on the "Logout from 3box" button. Wait until you are logged out.
  5. Open your Metamask. Select a different account. Make sure this new account is not linked with the 3box account you just logged out of.
  6. Refresh the page.
  7. Click on the "Auth 3box" button. The error appears in the console. You do not appear to be logged in with your new account.

Expected behavior Users should be able to log out of a 3box account and then log in to a different 3box account.

Screenshot 3boxError

Desktop:

I was also able to reproduce on Firefox Developer Edition 81.0b5

oed commented 3 years ago

I believe this will be solved by #901