From 52f04ba22447eee8629923eb61ef0337dcf9b541 Mon Sep 17 00:00:00 2001 From: ron8mcr Date: Tue, 24 Nov 2015 22:04:57 +0700 Subject: [PATCH] Update tests and fix register serializer --- rest_auth/registration/serializers.py | 10 ++++++++-- rest_auth/tests.py | 6 ++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rest_auth/registration/serializers.py b/rest_auth/registration/serializers.py index 68ba702..d3fcf1d 100644 --- a/rest_auth/registration/serializers.py +++ b/rest_auth/registration/serializers.py @@ -146,11 +146,17 @@ class RegisterSerializer(serializers.Serializer): def custom_signup(self, request, user): pass + def get_cleaned_data(self): + return { + 'username': self.validated_data.get('username', ''), + 'password1': self.validated_data.get('password', ''), + 'email': self.validated_data.get('email', '') + } + def save(self, request): adapter = get_adapter() user = adapter.new_user(request) - self.cleaned_data = self.validated_data - self.cleaned_data['password1'] = self.cleaned_data['password'] + self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) diff --git a/rest_auth/tests.py b/rest_auth/tests.py index 4e5a1c2..3fa749d 100644 --- a/rest_auth/tests.py +++ b/rest_auth/tests.py @@ -138,8 +138,7 @@ class APITestCase1(TestCase, BaseAPITestCase): # data without user profile REGISTRATION_DATA = { "username": USERNAME, - "password1": PASS, - "password2": PASS + "password": PASS, } REGISTRATION_DATA_WITH_EMAIL = REGISTRATION_DATA.copy() @@ -432,8 +431,7 @@ class TestSocialAuth(TestCase, BaseAPITestCase): EMAIL = "person1@world.com" REGISTRATION_DATA = { "username": USERNAME, - "password1": PASS, - "password2": PASS, + "password": PASS, "email": EMAIL }