enhancements in PasswordResetConfirm and Register views

This commit is contained in:
Mateusz Sikora 2014-05-05 21:01:23 +02:00
parent 1cf6052a31
commit d33bbc8021
2 changed files with 9 additions and 2 deletions

View File

@ -118,6 +118,10 @@ class SetPasswordSerializer(serializers.Serializer):
new_password1 = serializers.CharField(max_length=128)
new_password2 = serializers.CharField(max_length=128)
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user', None)
return super(SetPasswordSerializer, self).__init__(*args, **kwargs)
class PasswordResetSerializer(serializers.Serializer):

View File

@ -148,7 +148,10 @@ class Register(LoggedOutRESTAPIView, GenericAPIView):
# TODO: Make this customizable backend via settings.
# Call RESTRegistrationView().register to create new Django User
# and UserProfile models
RESTRegistrationView().register(request, **serializer.data)
data = serializer.data.copy()
data.update(profile_serializer.data)
RESTRegistrationView().register(request, **data)
# Return the User object with Created HTTP status
return Response(UserDetailsSerializer(serializer.data).data,
@ -272,7 +275,7 @@ class PasswordResetConfirm(LoggedOutRESTAPIView, GenericAPIView):
# If we get the User object
if user:
serializer = self.serializer_class(data=request.DATA)
serializer = self.serializer_class(data=request.DATA, user=user)
if serializer.is_valid():
# Construct SetPasswordForm instance