Internet Identity logins while navigating to different pages

Hi
I have been playing with the local internet identity canister.

My dapp has multiple pages = a.html, b.html, c.html, …, z.html
I ran into a problem when I was testing the navigation. It seems that when I login as user A on page B, then navigate to page C, logout, and login as user D, but when i click “back”, page B still thinks i’m user A, and this is messing up the identity that I’m passing to my actors. Was Internet Identity designed for 1-page dapps only?

I use onpageshow event to run await authClient.isAuthenticated() and authClient.getIdentity().

the error

I’m out of ideas on what to do next.

Can you try to set authClient = null after logout. Does it help?

Typically something I do on my state to prevent issue with the “sign in → sign out → sign in again” flow when the window is not reloaded.

https://github.com/buildwithjuno/juno/blob/5b7bf0cf41be821c4e14b9d0ba5078d879b2c2dd/src/frontend/src/lib/stores/auth.store.ts#L77

1 Like

thanks peter, it works! Looks like the authClient is exclusively for 1 user at a time only.

1 Like

Out of the box, I think so. However I believe it may possible to have multiple instances of the client by passing a custom storage object in the constructor. However, even if this is the case, it would still be useful to reset each instance after logout. I’m glad it worked out!