Open fengsi opened 8 years ago
Let me add a few details and a workaround to this. (allauth 0.38.0, rest_auth 0.9.3)
AUTH_PASSWORD_VALIDATORS
.You can define a custom adapter (in your settings.py
) with the following code to honor the setting for signup:
from allauth.account.adapter import DefaultAccountAdapter
from django.core.exceptions import ValidationError as DjangoValidationError
from rest_framework.exceptions import ValidationError
class RestAdapter(DefaultAccountAdapter):
def save_user(self, request, user, form, commit=True):
user = super().save_user(request, user, form, commit=False)
try:
self.clean_password(form.cleaned_data['password1'], user=user)
except DjangoValidationError as e:
raise ValidationError(e.messages)
if commit:
user.save()
return user
Title said it all.