ResendLinkView: Change text and logic of rate limiting

This commit is contained in:
Raphael Michel
2021-01-26 16:52:08 +01:00
parent 41c69aaa2a
commit e33d15429e

View File

@@ -32,11 +32,14 @@ class ResendLinkView(EventViewMixin, TemplateView):
if settings.HAS_REDIS:
from django_redis import get_redis_connection
rc = get_redis_connection("redis")
if rc.exists('pretix_resend_{}'.format(user)):
messages.error(request, _('We already sent you an email in the last 24 hours.'))
if rc.exists('pretix_resend_{}_{}'.format(request.event.pk, user)):
messages.error(request, _('If the email address you entered is valid and associated with a ticket, we have '
'already sent you an email with a link to your ticket in the past {number} hours. '
'If the email did not arrive, please your check spam folder and also double check '
'that you used the correct email address.').format(number=24))
return redirect(eventreverse(self.request.event, 'presale:event.resend_link'))
else:
rc.setex('pretix_resend_{}'.format(user), 3600 * 24, '1')
rc.setex('pretix_resend_{}_{}'.format(request.event.pk, user), 3600 * 24, '1')
orders = self.request.event.orders.filter(email__iexact=user)