fix bug in PasswordChangeSerializer

This commit is contained in:
Mateusz Sikora 2014-11-14 10:31:02 +01:00
parent 986dcd12c0
commit 7b7e2d368b

View File

@ -136,10 +136,10 @@ class PasswordChangeSerializer(serializers.Serializer):
self.fields.pop('old_password')
self.request = self.context.get('request')
self.user = self.request.user
self.user = getattr(self.request, 'user', None)
def validate_old_password(self, attrs, source):
if self.old_password_field_enabled and \
if self.old_password_field_enabled and self.user and \
not self.user.check_password(attrs.get(source, '')):
raise serializers.ValidationError('Invalid password')
return attrs