Created
September 8, 2015 13:01
-
-
Save oertels/062946b0592c35bb38e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django.http import HttpResponseRedirect | |
from django.conf import settings | |
class LoginRequired(object): | |
def __init__(self): | |
self.login_url = getattr(settings, 'LOGIN_URL', '/accounts/login/') | |
def process_request(self, request): | |
""" | |
Ensure that user is authenticated when accessing a Django-CMS page | |
""" | |
if getattr(request, 'current_page', None) and not request.user.is_authenticated(): | |
return HttpResponseRedirect("%s?next=%s" % (self.login_url, request.path)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment