fix: Fix filter attribute in rate limiting logic

Corrects the attribute name used in IPBlock filtering
from 'expiry' to 'expires'. This ensures that the rate
limit check properly references the intended field to
evaluate expiration against the current time.
This commit is contained in:
Kumi 2024-12-21 22:06:25 +01:00
parent e15224ca69
commit cae8d07431
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -23,7 +23,7 @@ class RateLimitMixin:
else: else:
ip_address = request.META.get("HTTP_X_FORWARDED_FOR") ip_address = request.META.get("HTTP_X_FORWARDED_FOR")
for block in IPBlock.objects.filter(expiry__gt=timezone.now()): for block in IPBlock.objects.filter(expires__gt=timezone.now()):
if ip_network(ip_address) in ip_network(f"{block.network}/{block.netmask}"): if ip_network(ip_address) in ip_network(f"{block.network}/{block.netmask}"):
return render(request, "registration/ratelimit.html", status=429) return render(request, "registration/ratelimit.html", status=429)