def METHOD_NAME(function):
    """Session based rate limiting for POST requests."""
    def rate_wrap(request, *args, **kwargs):
        if request.method == "POST" and not check_rate_limit(scope, request):
            # Rotate session token
            rotate_token(request)
            if not logout_user:
                messages.error(
                    request,
                    render_to_string(
                        "ratelimit.html", {"do_logout": False, "user": request.user}
                    ),
                )
                return redirect(request.get_full_path())
            # Logout user
            do_logout = request.user.is_authenticated
            if do_logout:
                logout(request)
            messages.error(
                request,
                render_to_string(
                    "ratelimit.html", {"do_logout": do_logout, "user": request.user}
                ),
            )
            return redirect("login")
        return function(request, *args, **kwargs)
    return rate_wrap