def reject_request(request): if request.headers.get('x-requested-with') == 'XMLHttpRequest': raise PermissionDenied # import redirect_to_login here to avoid circular imports on model files that import # wagtail.admin.auth, specifically where custom user models are involved from django.contrib.auth.views import redirect_to_login as auth_redirect_to_login return auth_redirect_to_login(request.get_full_path(), login_url=reverse('wagtailadmin_login'))
def redirect_to_login(request, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): """redirect to login""" path = request.build_absolute_uri() # if the login url is the same scheme and net location then just # use the path as the "next" url. login_scheme, login_netloc = urlparse.urlparse(login_url or settings.LOGIN_URL)[:2] current_scheme, current_netloc = urlparse.urlparse(path)[:2] if ((not login_scheme or login_scheme == current_scheme) and (not login_netloc or login_netloc == current_netloc)): path = request.get_full_path() from django.contrib.auth.views import redirect_to_login as auth_redirect_to_login return auth_redirect_to_login(path, login_url, redirect_field_name)
def redirect_to_login( request, favorite_url, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None, ): """Redirects the user to the login page.""" resolved_favorite_url = resolve_url(favorite_url) resolved_login_url = resolve_url(login_url or settings.LOGIN_URL) return auth_redirect_to_login(resolved_favorite_url, resolved_login_url, redirect_field_name)
def redirect_to_login(request, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): """redirect to login""" path = request.build_absolute_uri() # if the login url is the same scheme and net location then just # use the path as the "next" url. login_scheme, login_netloc = \ urlparse(login_url or settings.LOGIN_URL)[:2] current_scheme, current_netloc = urlparse(path)[:2] if ((not login_scheme or login_scheme == current_scheme) and (not login_netloc or login_netloc == current_netloc)): path = request.get_full_path() from django.contrib.auth.views import \ redirect_to_login as auth_redirect_to_login return auth_redirect_to_login(path, login_url, redirect_field_name)
def redirect_to_login(request, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None): """Redirects the user to the login page.""" path = request.build_absolute_uri() resolved_login_url = resolve_url(login_url or settings.LOGIN_URL) # If the login url is the same scheme and net location then just # use the path as the "next" url. login_scheme, login_netloc = urlparse(resolved_login_url)[:2] current_scheme, current_netloc = urlparse(path)[:2] if (not login_scheme or login_scheme == current_scheme) and ( not login_netloc or login_netloc == current_netloc): path = request.get_full_path() return auth_redirect_to_login(path, resolved_login_url, redirect_field_name)
def redirect_to_login( request, favorite_url, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None, ): """Redirects the user to the login page.""" resolved_favorite_url = resolve_url(favorite_url) resolved_login_url = resolve_url(login_url or settings.LOGIN_URL) # If the login url is the same scheme and net location then just # use the path as the "next" url. login_scheme, login_netloc = urlparse(resolved_login_url)[:2] favorite_scheme, favorite_netloc = urlparse(resolved_favorite_url)[:2] if (not login_scheme or login_scheme == favorite_scheme) and ( not login_netloc or login_netloc == favorite_netloc): resolved_favorite_url = request.get_full_path() return auth_redirect_to_login(resolved_favorite_url, resolved_login_url, redirect_field_name)
def redirect_to_login(request): return auth_redirect_to_login( request.get_full_path(), login_url=reverse('wagtailadmin_login'))
def redirect_to_login(request): return auth_redirect_to_login(request.get_full_path(), login_url=reverse('wagtailadmin_login'))
def reject_request(request): if request.is_ajax(): raise PermissionDenied return auth_redirect_to_login(request.get_full_path(), login_url=reverse('wagtailadmin_login'))
def reject_request(request): if request.is_ajax(): raise PermissionDenied return auth_redirect_to_login( request.get_full_path(), login_url=reverse('wagtailadmin_login'))