Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegisterSerializer has a 'get_cleaned_data' method that sets undefined fields to empty strings #444

Open
ardenn opened this issue Jul 11, 2018 · 0 comments

Comments

@ardenn
Copy link

ardenn commented Jul 11, 2018

Hi, I just noticed something weird with the RegisterSerializer. It has a get_cleaned_data method that seems to assign empty strings to fields whose values haven't been passed during registration. For instance, if I choose to register without a password1 value, then the all-auth adapter sets the password using set_unusable_password().

Presently am working on a project that requires users to be registered without passwords (i.e set_unusable_password() ). So I had to override get_cleaned_data method to make sure password1 is None instead of an empty string.

Shouldn't this be the default implementation? (my thoughts)

class RegisterSerializer(serializers.Serializer):
    ...
   def get_cleaned_data(self):
        return {
            'username': self.validated_data.get('username', ''),
            'password1': self.validated_data.get('password1', ''),
            'email': self.validated_data.get('email', '')
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant