Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Logout Behavior and Session Management #474

Closed
gkatrakazas opened this issue Dec 2, 2024 · 2 comments · Fixed by #488
Closed

Improve Logout Behavior and Session Management #474

gkatrakazas opened this issue Dec 2, 2024 · 2 comments · Fixed by #488
Labels
bug Something isn't working

Comments

@gkatrakazas
Copy link
Member

Currently, the logout function in SessionContext is called on user logout. However, in certain cases, such as:

  • User inactivity leading to automatic logout
  • Login/Signup from a different user in any tab leading to automatic logout the other users tabs.

The SessionStorage from api/index.ts is not cleaned up, leading to potential issues.
Additionally, it would be beneficial to set sessionStorage.setItem('freshLogin', 'true'); during the logout process. This ensures any login/signup from each logout tab will be login with clean url

@gkatrakazas gkatrakazas added the bug Something isn't working label Dec 2, 2024
@emlun
Copy link
Member

emlun commented Dec 3, 2024

PR #483 resolves part of this, but the issue with logging in to the wrong user is slightly different. The cause is that after successfully logging in and unlocking the keystore, this code runs to update the cached users (to copy the prfKeys from the logged-in user's privateData to the matching cached user):

if (privateData && userHandleB64u && (userHandleB64u === globalUserHandleB64u)) {
// When PRF keys are added, deleted or edited in any tab,
// propagate changes to cached users
setCachedUsers((cachedUsers) => cachedUsers.map((cu) => {
if (cu.userHandleB64u === userHandleB64u) {
return {
...cu,
prfKeys: privateData.prfKeys.map((keyInfo) => ({
credentialId: keyInfo.credentialId,
transports: keyInfo.transports,
prfSalt: keyInfo.prfSalt,
})),
};
} else {
return cu;
}
}));

But when there are two tabs open simultaneously, that code runs simultaneously in both tabs, and the globalUserHandleB64u is different between the two tabs. The user1 tab has globalUserHandleB64u set to the user handle of user1, and the user2 tab has globalUserHandleB64u set to the user handle of user2. So the result is that both cached users get updated with user2's prfKeys. I'm looking into this too, but this is a bit trickier to solve.

@gkatrakazas
Copy link
Member Author

This issue was fixed in PR #488.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants