Exemple #1
0
    def _inner(request, domain, *args, **kwargs):
        response = f(request, domain, *args, **kwargs)
        if response.status_code == 401:
            auth_type = determine_authtype_from_request(request)
            if auth_type and auth_type == 'basic':
                username, password = get_username_and_password_from_request(request)
                if username:
                    valid, message, error_code = ensure_active_user_by_username(username)
                    if not valid:
                        return json_response({
                            "error": error_code,
                            "default_response": message
                        }, status_code=406)

        return response
Exemple #2
0
    def _inner(request, domain, *args, **kwargs):
        response = f(request, domain, *args, **kwargs)
        if response.status_code == 401:
            auth_type = determine_authtype_from_request(request)
            if auth_type and auth_type == 'basic':
                username, _ = get_username_and_password_from_request(request)
                if username:
                    valid, message, error_code = ensure_active_user_by_username(username)
                    if not valid:
                        return json_response({
                            "error": error_code,
                            "default_response": message
                        }, status_code=406)

        return response