summaryrefslogtreecommitdiff
path: root/lib/sitelogin.py
blob: 3edec7c1bac20396b6eee76cbed4bc461c312b49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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))