Code Monkey home page Code Monkey logo

Comments (4)

pennersr avatar pennersr commented on June 16, 2024

The purpose of the UserSession model is to be able to keep track of all the sessions a user has running. A UserSession instance itself does not represent a session, it is merely a pointer to an actual session. As it is not a session, it cannot replace the builtin Session model. Note that the builtin Session model is not at all aware of users, it is just a data payload pointed to by a session cookie, and there may or may not be a user attached to that session. The sessions app itself is not aware of users at all. All in all, I do not see a way of unifying this.

Could you elaborate a bit on potential problems you see, especially curious about the "cleaner implementation" bit.

from django-allauth.

dwasyl avatar dwasyl commented on June 16, 2024

@pennersr Fair enough, I just often end up using django-user-sessions which brings in a custom SessionEngine linking User to Session.

It's just a cleaner implementation using the swappable session model rather than creating the extra UserSession instance. Since Django allows for swapping in a different session backend, it seems like it would be cleaner to implement UserSession as a better session backend (rather than creating extra writes to the DB and extra joins with the separate model).

From taking a quick look, a session backend really only requires that UserSession inherits from AbstractBaseSession and a SessionStore model.

It also wouldn't need an additional middleware (just a single session middleware).

from django-allauth.

pennersr avatar pennersr commented on June 16, 2024

Whatever solution is chosen, it must be able to work with different session backends. Many projects use cache based sessions. So, the approach taken by django-user-sessions does not match our requirements. Also see:

jazzband/django-user-sessions#52

As for QSessions mentioned in that ticket, that one offers at least both db and cache as backends, but I really do think our current solution is as simple as it gets. It does not require adjustments to your regular sessions setup (e.g. no need to remove django.contrib.sessions from INSTALLED_APPS, no need to alter SESSION_ENGINE).

from django-allauth.

dwasyl avatar dwasyl commented on June 16, 2024

Fair enough, perhaps it's just one of those unnecessary overrides that doesn't derive much in he way of specific value vs the approach here. This is definitely quite a bit simpler!

from django-allauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.