From 28e712cf4b4784522589f4678ccf0d2a26e8cbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=C5=A1ek=20Dohnal?= Date: Wed, 25 Oct 2017 15:09:44 +0200 Subject: [PATCH] Password whitespace and input in browsable API - Do not trim password whitespace (`trim_whitespace`, see: http://www.django-rest-framework.org/api-guide/fields/#charfield) - Mask password input (inspired by https://github.com/encode/django-rest-framework/blob/master/rest_framework/authtoken/serializers.py#L11-L12) --- rest_auth/registration/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_auth/registration/serializers.py b/rest_auth/registration/serializers.py index c6b5d5b..ac5ad02 100644 --- a/rest_auth/registration/serializers.py +++ b/rest_auth/registration/serializers.py @@ -125,8 +125,8 @@ class RegisterSerializer(serializers.Serializer): required=allauth_settings.USERNAME_REQUIRED ) email = serializers.EmailField(required=allauth_settings.EMAIL_REQUIRED) - password1 = serializers.CharField(write_only=True) - password2 = serializers.CharField(write_only=True) + password1 = serializers.CharField(write_only=True, style={'input_type': 'password'}, trim_whitespace=False) + password2 = serializers.CharField(write_only=True, style={'input_type': 'password'}, trim_whitespace=False) def validate_username(self, username): username = get_adapter().clean_username(username)