mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-07 16:18:16 -06:00
17289 revert _post_clean
This commit is contained in:
parent
372bcbacc7
commit
e2b0516b30
@ -63,9 +63,6 @@ ADMINS = getattr(configuration, 'ADMINS', [])
|
|||||||
ALLOW_TOKEN_RETRIEVAL = getattr(configuration, 'ALLOW_TOKEN_RETRIEVAL', True)
|
ALLOW_TOKEN_RETRIEVAL = getattr(configuration, 'ALLOW_TOKEN_RETRIEVAL', True)
|
||||||
ALLOWED_HOSTS = getattr(configuration, 'ALLOWED_HOSTS') # Required
|
ALLOWED_HOSTS = getattr(configuration, 'ALLOWED_HOSTS') # Required
|
||||||
AUTH_PASSWORD_VALIDATORS = getattr(configuration, 'AUTH_PASSWORD_VALIDATORS', [
|
AUTH_PASSWORD_VALIDATORS = getattr(configuration, 'AUTH_PASSWORD_VALIDATORS', [
|
||||||
{
|
|
||||||
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
|
@ -2,7 +2,7 @@ from django import forms
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth import password_validation
|
from django.contrib.auth import password_validation
|
||||||
from django.contrib.postgres.forms import SimpleArrayField
|
from django.contrib.postgres.forms import SimpleArrayField
|
||||||
from django.core.exceptions import FieldError, ValidationError
|
from django.core.exceptions import FieldError
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
@ -221,21 +221,16 @@ class UserForm(forms.ModelForm):
|
|||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
def _post_clean(self):
|
|
||||||
super()._post_clean()
|
|
||||||
# Validate the password after self.instance is updated with form data
|
|
||||||
if self.cleaned_data['password']:
|
|
||||||
try:
|
|
||||||
password_validation.validate_password(self.cleaned_data['password'], self.instance)
|
|
||||||
except ValidationError as error:
|
|
||||||
self.add_error('password', error)
|
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|
||||||
# Check that password confirmation matches if password is set
|
# Check that password confirmation matches if password is set
|
||||||
if self.cleaned_data['password'] and self.cleaned_data['password'] != self.cleaned_data['confirm_password']:
|
if self.cleaned_data['password'] and self.cleaned_data['password'] != self.cleaned_data['confirm_password']:
|
||||||
raise forms.ValidationError(_("Passwords do not match! Please check your input and try again."))
|
raise forms.ValidationError(_("Passwords do not match! Please check your input and try again."))
|
||||||
|
|
||||||
|
# Enforce password validation rules (if configured)
|
||||||
|
if self.cleaned_data['password']:
|
||||||
|
password_validation.validate_password(self.cleaned_data['password'], self.instance)
|
||||||
|
|
||||||
|
|
||||||
class GroupForm(forms.ModelForm):
|
class GroupForm(forms.ModelForm):
|
||||||
users = DynamicModelMultipleChoiceField(
|
users = DynamicModelMultipleChoiceField(
|
||||||
|
Loading…
Reference in New Issue
Block a user