summaryrefslogtreecommitdiff
path: root/main/sitelogin.py
blob: 53721095a7cff5167e7ab30ccb137ff51fd69c8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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))

# vim: set ts=4 sw=4 et: