Skip to content

Commit 52f04ba

Browse files
committed
Update tests and fix register serializer
1 parent 65b29d3 commit 52f04ba

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

rest_auth/registration/serializers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,17 @@ def validate_password(self, password):
146146
def custom_signup(self, request, user):
147147
pass
148148

149+
def get_cleaned_data(self):
150+
return {
151+
'username': self.validated_data.get('username', ''),
152+
'password1': self.validated_data.get('password', ''),
153+
'email': self.validated_data.get('email', '')
154+
}
155+
149156
def save(self, request):
150157
adapter = get_adapter()
151158
user = adapter.new_user(request)
152-
self.cleaned_data = self.validated_data
153-
self.cleaned_data['password1'] = self.cleaned_data['password']
159+
self.cleaned_data = self.get_cleaned_data()
154160
adapter.save_user(request, user, self)
155161
self.custom_signup(request, user)
156162
setup_user_email(request, user, [])

rest_auth/tests.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ class APITestCase1(TestCase, BaseAPITestCase):
138138
# data without user profile
139139
REGISTRATION_DATA = {
140140
"username": USERNAME,
141-
"password1": PASS,
142-
"password2": PASS
141+
"password": PASS,
143142
}
144143

145144
REGISTRATION_DATA_WITH_EMAIL = REGISTRATION_DATA.copy()
@@ -432,8 +431,7 @@ class TestSocialAuth(TestCase, BaseAPITestCase):
432431
433432
REGISTRATION_DATA = {
434433
"username": USERNAME,
435-
"password1": PASS,
436-
"password2": PASS,
434+
"password": PASS,
437435
"email": EMAIL
438436
}
439437

0 commit comments

Comments
 (0)