1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #12238: Improve error message for API token IP prefix validation failures

This commit is contained in:
jeremystretch
2023-04-21 16:06:33 -04:00
parent 390619ca99
commit 053be952ba
2 changed files with 3 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ from django.utils.html import mark_safe
from django.utils.translation import gettext as _
from ipam.formfields import IPNetworkFormField
from ipam.validators import prefix_validator
from netbox.preferences import PREFERENCES
from utilities.forms import BootstrapMixin, DateTimePicker, StaticSelect
from utilities.utils import flatten_dict
@@ -104,7 +105,7 @@ class TokenForm(BootstrapMixin, forms.ModelForm):
help_text=_("If no key is provided, one will be generated automatically.")
)
allowed_ips = SimpleArrayField(
base_field=IPNetworkFormField(),
base_field=IPNetworkFormField(validators=[prefix_validator]),
required=False,
label=_('Allowed IPs'),
help_text=_('Allowed IPv4/IPv6 networks from where the token can be used. Leave blank for no restrictions. '