summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sitelogin.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/sitelogin.py b/lib/sitelogin.py
new file mode 100644
index 00000000..3edec7c1
--- /dev/null
+++ b/lib/sitelogin.py
@@ -0,0 +1,13 @@
+from django.contrib.auth.views import logout_then_login, login
+from django.conf import settings
+
+class SiteLogin:
+ def __init__(self):
+ self.login_path = settings.LOGIN_URL
+ def process_request(self, request):
+ if request.user.is_anonymous() and request.path != self.login_path:
+ if request.POST:
+ return login(request)
+ else:
+ return HttpResponseRedirect('%s?next=%s' % (self.login_path, request.path))
+