summaryrefslogtreecommitdiff
path: root/main/middleware.py
diff options
context:
space:
mode:
Diffstat (limited to 'main/middleware.py')
-rw-r--r--main/middleware.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/main/middleware.py b/main/middleware.py
index 01734f5e..df0a7a4b 100644
--- a/main/middleware.py
+++ b/main/middleware.py
@@ -31,6 +31,7 @@ from django.conf import settings
from django.contrib.auth.views import login
from django.http import HttpResponseRedirect
import re
+import threading
class RequireLoginMiddleware(object):
"""
@@ -50,3 +51,17 @@ class RequireLoginMiddleware(object):
else:
return HttpResponseRedirect('%s?next=%s' % (settings.LOGIN_URL, request.path))
+
+user_holder = threading.local()
+user_holder.user = None
+
+class AutoUserMiddleware(object):
+ '''Saves the current user so it can be retrieved by the admin'''
+ def process_request(self, request):
+ user_holder.user = request.user
+
+
+def get_user():
+ '''Get the currently logged in request.user'''
+ return user_holder.user
+