hapytex / django-single-session

Allow a user to only have a single active session in Django.
https://pypi.org/project/django-single-session/
BSD 3-Clause "New" or "Revised" License
16 stars 7 forks source link

Support single session for a subset of users #1

Closed alastair closed 1 year ago

alastair commented 1 year ago

Hi, thanks for the project, very useful! I have a requirement to have a single session only for a subset of users (e.g. consider a user on a free trial where we don't want them to share login details). In this case, in addition to the SINGLE_USER_SESSION setting, it might be useful to have a setting which is a callback that takes a user object, and returns True or False depending on if other sessions should be signed out or not.

Does this sound like something that could be added? If so, I'm happy to contribute the changes in a PR.

KommuSoft commented 1 year ago

Yes, looks like an excellent idea! Perhaps accept True (always), False (never), or a string that is a path to a function that takes the user as parameter.

KommuSoft commented 1 year ago

Finally got time to review and merge. Big thanks!