mirror of
				https://github.com/Tivix/django-rest-auth.git
				synced 2025-10-31 07:47:33 +03:00 
			
		
		
		
	enhancements in PasswordResetConfirm and Register views
This commit is contained in:
		
							parent
							
								
									1cf6052a31
								
							
						
					
					
						commit
						d33bbc8021
					
				|  | @ -118,6 +118,10 @@ class SetPasswordSerializer(serializers.Serializer): | ||||||
|     new_password1 = serializers.CharField(max_length=128) |     new_password1 = serializers.CharField(max_length=128) | ||||||
|     new_password2 = 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): | class PasswordResetSerializer(serializers.Serializer): | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -148,7 +148,10 @@ class Register(LoggedOutRESTAPIView, GenericAPIView): | ||||||
|             # TODO: Make this customizable backend via settings. |             # TODO: Make this customizable backend via settings. | ||||||
|             # Call RESTRegistrationView().register to create new Django User |             # Call RESTRegistrationView().register to create new Django User | ||||||
|             # and UserProfile models |             # 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 the User object with Created HTTP status | ||||||
|             return Response(UserDetailsSerializer(serializer.data).data, |             return Response(UserDetailsSerializer(serializer.data).data, | ||||||
|  | @ -272,7 +275,7 @@ class PasswordResetConfirm(LoggedOutRESTAPIView, GenericAPIView): | ||||||
| 
 | 
 | ||||||
|         # If we get the User object |         # If we get the User object | ||||||
|         if user: |         if user: | ||||||
|             serializer = self.serializer_class(data=request.DATA) |             serializer = self.serializer_class(data=request.DATA, user=user) | ||||||
| 
 | 
 | ||||||
|             if serializer.is_valid(): |             if serializer.is_valid(): | ||||||
|                 # Construct SetPasswordForm instance |                 # Construct SetPasswordForm instance | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user