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

if one person login with two diffrent device, how to keep just one session alive? #109

Closed
virtoolswebplayer opened this issue Dec 2, 2016 · 2 comments
Labels
support Questions, discussions, and general support

Comments

@virtoolswebplayer
Copy link

two questions

  1. how to list all sessions?
  2. if one person login with two diffrent device, how to keep just one session alive?
@mark-bradshaw
Copy link
Contributor

Hi @virtoolswebplayer.

Regarding #1, there's not a good way to do this IMO. The sessions get stored in the Hapi server cache with a random UUID. Neither yar nor cache provide a means to list everything in it, and there's not an obvious way to pick them out of other possible cached data. However you could implement customSessionIDGenerator in your yar options and use that to either generate easily recognizable session ids that you could perhaps locate directly from an externally backed cache (not the default in-memory implementation), or keep track of all session ids you generate in a separate location outside of yar.

You'd also need to deal with figuring out which sessions had timed out. Yar doesn't track this proactively, but rather relies on the built in cache expiration functionality of catbox to do the hard work. Even if you got a list of all issued session ids, you'd need to go out to the cache and to figure out which ones were still active.

Regarding #2, a typical way to do this is to make note of the active session per user whenever a person logs in, and recheck this as part of your authentication mechanism. For speed you might do this in a separate redis cache to avoid hitting a slower db. Whenever the user logs in again from a new device, the new session id is noted in your cache, and the old one will no longer validate.

@Marsup Marsup added support Questions, discussions, and general support and removed question labels Sep 21, 2019
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

3 participants