Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Enable password validators on registration

Marcin Gębala127d392f6881
diff --git a/saleor/graphql/account/mutations/account.py b/saleor/graphql/account/mutations/account.py
index f72dc4ffda..494eb98e4d 100644
--- a/saleor/graphql/account/mutations/account.py
+++ b/saleor/graphql/account/mutations/account.py
@@ -1,5 +1,6 @@
import graphene
from django.conf import settings
+from django.contrib.auth import password_validation
from django.contrib.auth.tokens import default_token_generator
from django.core.exceptions import ValidationError
@@ -81,6 +82,12 @@ class AccountRegister(ModelMutation):
}
)
+ password = data["password"]
+ try:
+ password_validation.validate_password(password, instance)
+ except ValidationError as error:
+ raise ValidationError({"password": error})
+
return super().clean_input(info, instance, data, input_cls=None)
@classmethod
@@ -378,7 +385,7 @@ class RequestEmailChange(BaseMutation):
if not user.check_password(password):
raise ValidationError(
{
- "user_password": ValidationError(
+ "password": ValidationError(
"Password isn't valid.", code=AccountErrorCode.INVALID_PASSWORD
)
}