Commit 6ee7a936 authored by eliott's avatar eliott
Browse files

initial stab at an authentication middleware

parent 6226b02f
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)
return HttpResponseRedirect('%s?next=%s' % (self.login_path, request.path))
......@@ -40,6 +40,9 @@
# URL to send users when they don't have sufficient privileges
BADPRIVS_URL = '/denied/'
# login url
LOGIN_URL = '/login/'
# List of callables that know how to import templates from various sources.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment