mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Allow to configure length of ticket secret
This commit is contained in:
@@ -694,6 +694,7 @@ class EventSettingsSerializer(SettingsSerializer):
|
||||
'ticket_download_nonadm',
|
||||
'ticket_download_pending',
|
||||
'ticket_download_require_validated_email',
|
||||
'ticket_secret_length',
|
||||
'mail_prefix',
|
||||
'mail_from',
|
||||
'mail_from_name',
|
||||
|
||||
@@ -29,7 +29,6 @@ from cryptography.hazmat.primitives.serialization import (
|
||||
Encoding, NoEncryption, PrivateFormat, PublicFormat, load_pem_private_key,
|
||||
load_pem_public_key,
|
||||
)
|
||||
from django.conf import settings
|
||||
from django.dispatch import receiver
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@@ -111,7 +110,7 @@ class RandomTicketSecretGenerator(BaseTicketSecretGenerator):
|
||||
if current_secret and not force_invalidate:
|
||||
return current_secret
|
||||
return get_random_string(
|
||||
length=settings.ENTROPY['ticket_secret'],
|
||||
length=self.event.settings.ticket_secret_length,
|
||||
# Exclude o,0,1,i,l to avoid confusion with bad fonts/printers
|
||||
allowed_chars='abcdefghjkmnpqrstuvwxyz23456789'
|
||||
)
|
||||
|
||||
@@ -461,6 +461,32 @@ DEFAULTS = {
|
||||
'default': 'random',
|
||||
'type': str,
|
||||
},
|
||||
'ticket_secret_length': {
|
||||
'default': settings.ENTROPY['ticket_secret'],
|
||||
'type': int,
|
||||
'form_class': forms.IntegerField,
|
||||
'serializer_class': serializers.IntegerField,
|
||||
'serializer_kwargs': dict(
|
||||
validators=[
|
||||
MinValueValidator(12),
|
||||
MaxValueValidator(64),
|
||||
]
|
||||
),
|
||||
'form_kwargs': dict(
|
||||
label=_('Length of ticket codes'),
|
||||
validators=[
|
||||
MinValueValidator(12),
|
||||
MaxValueValidator(64),
|
||||
],
|
||||
widget=forms.NumberInput(
|
||||
attrs={
|
||||
'min': '12',
|
||||
'max': '64',
|
||||
'data-display-dependency': 'input[name=ticket_secret_generator][value=random]',
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
'reservation_time': {
|
||||
'default': '30',
|
||||
'type': int,
|
||||
|
||||
@@ -1083,6 +1083,7 @@ class TicketSettingsForm(SettingsForm):
|
||||
'ticket_download_nonadm',
|
||||
'ticket_download_pending',
|
||||
'ticket_download_require_validated_email',
|
||||
'ticket_secret_length',
|
||||
]
|
||||
ticket_secret_generator = forms.ChoiceField(
|
||||
label=_("Ticket code generator"),
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
<fieldset>
|
||||
<legend>{% trans "Ticket codes" %}</legend>
|
||||
{% bootstrap_field form.ticket_secret_generator layout="control" %}
|
||||
{% bootstrap_field form.ticket_secret_length layout="control" %}
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="form-group submit-group">
|
||||
|
||||
Reference in New Issue
Block a user