You could check things like IP address and user agent, but these are imperfect identifiers (generating false positives and false negatives). You should also decide if you really need this level of security, as users may legitimately want to be logged in from multiple places (e.g., from laptop as well as tablet or phone). I'm currently logged into Google Groups from three different devices and would be quite annoyed if I had to keep logging in again when I move between devices.
e
Is it possible to either :
not allow login from MachineB (show message that "You are currently logged in from MachineA - continue to access the application from MachineA, or logout from MachineA"... or some such message.)
OR
allow login from MachineB - but forcefully log out userA from MachineA (since login from MachineB was later)
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Z3gjaLzM65E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Let me clarify a little - since lot of answer seemed to focus on "MachineA Vs MachineB"What I need is "only one valid session from UserA at given point" - so two sessions - one from Chrome and other from Firefox - both from MachineA - should be disallowed. (Not sure if it makes problem easy or difficult)
in pre-login (if I can intercept login attempt) - put a code that checks whether user that is trying to login - has already logged in (and not logged out yet) If yes, do not allow the login (or somehow forcely invalidate "other" session - and allow "this" login attempt to go thru)Theoretically I am thinking following :
in pre-login (if I can intercept login attempt) - put a code that checks whether user that is trying to login - has already logged in (and not logged out yet) If yes, do not allow the login (or somehow forcely invalidate "other" session - and allow "this" login attempt to go thru)Theoretically I am thinking following :
Maybe add a session_id field to db.auth_user, and when a user logs in (a) check that field, and if it has a value, delete the session file associated with the existing ID (if it exists) and (b) store the new session_id. Note, this won't work with cookie based sessions -- in that case, you would instead have to check the session_id value stored in db.auth_user on every request in order to catch and invalidate the session cookie from the older session (this adds a db lookup to every request -- might want to cache these in RAM, though you may need to clean up periodically if there are a large number of users).
Also, note that this doesn't protect against session hijacking. It only protects against multiple simultaneous logins (which would be using different sessions rather than sharing a single hijacked session).