From da0f3f1143d6d5c27d7ab0106373ebbb2e4eda8a Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 11 Dec 2014 20:24:55 -0400 Subject: [PATCH] Allow the user password to be changed from the user API endpoint --- mayan/apps/user_management/serializers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mayan/apps/user_management/serializers.py b/mayan/apps/user_management/serializers.py index 8fd7e3acef..6bd9ef5501 100644 --- a/mayan/apps/user_management/serializers.py +++ b/mayan/apps/user_management/serializers.py @@ -7,13 +7,15 @@ from rest_framework import serializers class UserSerializer(serializers.ModelSerializer): class Meta: - fields = ('id', 'username', 'first_name', 'last_name', 'email', 'is_staff', 'is_active', 'is_superuser', 'last_login', 'date_joined') + fields = ('id', 'username', 'first_name', 'last_name', 'email', 'is_staff', 'is_active', 'is_superuser', 'last_login', 'date_joined', 'password') model = User + read_only_fields = ('last_login', 'date_joined') write_only_fields = ('password',) def restore_object(self, attrs, instance=None): user = super(UserSerializer, self).restore_object(attrs, instance) - user.set_password(attrs['password']) + if 'password' in attrs: + user.set_password(attrs['password']) return user