Codebase list django-stronghold / d533abb
Merge pull request #60 from mcallistersean/master new style middleware Mike Grouchy authored 6 years ago GitHub committed 6 years ago
2 changed file(s) with 10 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
00 from django.contrib.auth.decorators import user_passes_test
11 from stronghold import conf, utils
22
3 try:
4 from django.utils.deprecation import MiddlewareMixin
5 except ImportError:
6 MiddlewareMixin = object
37
4 class LoginRequiredMiddleware(object):
8
9 class LoginRequiredMiddleware(MiddlewareMixin):
510 """
611 Restrict access to users that for which STRONGHOLD_USER_TEST_FUNC returns
712 True. Default is to check if the user is authenticated.
1520 """
1621
1722 def __init__(self, *args, **kwargs):
23 if MiddlewareMixin != object:
24 super(LoginRequiredMiddleware, self).__init__(*args, **kwargs)
1825 self.public_view_urls = getattr(conf, 'STRONGHOLD_PUBLIC_URLS', ())
1926
2027 def process_view(self, request, view_func, view_args, view_kwargs):
6464 'stronghold.middleware.LoginRequiredMiddleware',
6565 )
6666
67 MIDDLEWARE = MIDDLEWARE_CLASSES
68
6769 ROOT_URLCONF = 'test_project.urls'
6870
6971 # Python dotted path to the WSGI application used by Django's runserver.