def decorator(request, *args, **kwargs):
     protected_view = get_protected_namespace(request)
     if protected_view:
         if is_admin_session(request):
             update_admin_session(request)
             return f(request, *args, **kwargs)
         else:
             request.admin_namespace = protected_view
             return login(request)
     else:
         return f(request, *args, **kwargs)
Beispiel #2
0
 def decorator(request, *args, **kwargs):
     protected_view = get_protected_namespace(request)
     if protected_view:
         if is_admin_session(request):
             update_admin_session(request)
             return f(request, *args, **kwargs)
         else:
             request.admin_namespace = protected_view
             return login(request)
     else:
         return f(request, *args, **kwargs)
def _error_page(request, code, exception=None, default_message=None):
    if is_admin_session(request):
        template_pattern = 'misago/admin/errorpages/%s.html' % code

        response = render(request, template_pattern, {
            'message': get_exception_message(exception, default_message),
        }, error_page=True)
        response.status_code = code
        return response
    else:
        return redirect('misago:admin:index')
Beispiel #4
0
def _error_page(request, code, message=None):
    if is_admin_session(request):
        template_pattern = 'misago/admin/errorpages/%s.html' % code

        response = render(request,
                          template_pattern, {'message': message},
                          error_page=True)
        response.status_code = code
        return response
    else:
        return redirect('misago:admin:index')
Beispiel #5
0
def _csrf_failure(request, reason=""):
    if is_admin_session(request):
        update_admin_session(request)
        response = render(
            request, 'misago/admin/errorpages/csrf_failure_authenticated.html',
            error_page=True)
    else:
        response = render(request, 'misago/admin/errorpages/csrf_failure.html')

    response.status_code = 403
    return response
Beispiel #6
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        request.admin_namespace = get_protected_namespace(request)

        if request.admin_namespace:
            if not auth.is_admin_session(request):
                auth.close_admin_session(request)
                if request.resolver_match.url_name == 'index':
                    return login(request)
                else:
                    return redirect('%s:index' % request.admin_namespace)
            else:
                auth.update_admin_session(request)
Beispiel #7
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        request.admin_namespace = get_protected_namespace(request)

        if request.admin_namespace:
            if not auth.is_admin_session(request):
                auth.close_admin_session(request)
                if request.resolver_match.url_name == "index":
                    return login(request)
                else:
                    return redirect("%s:index" % request.admin_namespace)
            else:
                auth.update_admin_session(request)