v0.0.00.5
This commit is contained in:
parent
f7e49dfceb
commit
62464ea1a7
@ -1,23 +1,23 @@
|
||||
from django.conf import settings
|
||||
from django.shortcuts import redirect
|
||||
import re
|
||||
# from django.conf import settings
|
||||
# from django.shortcuts import redirect
|
||||
# import re
|
||||
|
||||
EXEMPT_URLS = [
|
||||
re.compile(settings.LOGIN_URL.lstrip('/')), # eg. 'streaming/login/'
|
||||
re.compile(r'^admin/login/$'), # админ-логин
|
||||
re.compile(r'^streaming/login/$'), # <-- добавь это!
|
||||
re.compile(r'^streaming/$'),
|
||||
re.compile(r'^static/'),
|
||||
re.compile(r'^media/'),
|
||||
]
|
||||
# EXEMPT_URLS = [
|
||||
# re.compile(settings.LOGIN_URL.lstrip('/')), # eg. 'streaming/login/'
|
||||
# re.compile(r'^admin/login/$'), # админ-логин
|
||||
# re.compile(r'^streaming/login/$'), # <-- добавь это!
|
||||
# re.compile(r'^streaming/$'),
|
||||
# re.compile(r'^static/'),
|
||||
# re.compile(r'^media/'),
|
||||
# ]
|
||||
|
||||
class LoginRequiredMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
# class LoginRequiredMiddleware:
|
||||
# def __init__(self, get_response):
|
||||
# self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
path = request.path_info.lstrip('/')
|
||||
if not request.user.is_authenticated:
|
||||
if not any(pattern.match(path) for pattern in EXEMPT_URLS):
|
||||
return redirect(settings.LOGIN_URL)
|
||||
return self.get_response(request)
|
||||
# def __call__(self, request):
|
||||
# path = request.path_info.lstrip('/')
|
||||
# if not request.user.is_authenticated:
|
||||
# if not any(pattern.match(path) for pattern in EXEMPT_URLS):
|
||||
# return redirect(settings.LOGIN_URL)
|
||||
# return self.get_response(request)
|
||||
Loading…
x
Reference in New Issue
Block a user