mirror of
https://github.com/fergalmoran/dss.api.git
synced 2025-12-28 04:09:51 +00:00
14 lines
424 B
Python
14 lines
424 B
Python
from django.contrib import auth
|
|
|
|
|
|
class AuthenticationMiddleware(object):
|
|
def process_request(self, request):
|
|
user_cookie_name = "session_key"
|
|
if user_cookie_name not in request.COOKIES:
|
|
# log user out if you want
|
|
return
|
|
id = request.COOKIES.get(user_cookie_name)
|
|
# this will find the right backend
|
|
user = auth.authenticate(id)
|
|
request.user = user
|