Open belugame opened 7 years ago
Currently the order in which this middleware is inserted in respect to AuthenticationMiddleware and SessionMiddleware does not matter as we use a closure that returns the request-scope only on-demand.
AuthenticationMiddleware
SessionMiddleware
This closure can fail in certain setups (see https://github.com/PaesslerAG/django-currentuser/pull/1#discussion_r112193050) and seems avoidable. Right now nothing speaks against requiring a fixed order where ThreadLocalUserMiddleware is only allowed after the other two.
ThreadLocalUserMiddleware
See: https://github.com/PaesslerAG/django-currentuser/blob/mb-prepare-package/django_currentuser/middleware.py#L29
Currently the order in which this middleware is inserted in respect to
AuthenticationMiddleware
andSessionMiddleware
does not matter as we use a closure that returns the request-scope only on-demand.This closure can fail in certain setups (see https://github.com/PaesslerAG/django-currentuser/pull/1#discussion_r112193050) and seems avoidable. Right now nothing speaks against requiring a fixed order where
ThreadLocalUserMiddleware
is only allowed after the other two.See: https://github.com/PaesslerAG/django-currentuser/blob/mb-prepare-package/django_currentuser/middleware.py#L29