Fix for AC-257. Handle setting/updating password through UserSerializer.

This commit is contained in:
Chris Church
2013-07-25 15:20:44 -04:00
parent 7fc08767f6
commit 9916a5eefb
2 changed files with 47 additions and 36 deletions

View File

@@ -310,16 +310,6 @@ class UserList(ListCreateAPIView):
model = User
serializer_class = UserSerializer
def create(self, request, *args, **kwargs):
password = request.DATA.get('password', None)
response = super(UserList, self).create(request, *args, **kwargs)
if password:
pk = response.data['id']
user = User.objects.get(pk=pk)
user.set_password(password)
user.save()
return response
class UserMeList(ListAPIView):
model = User
@@ -408,11 +398,6 @@ class UserDetail(RetrieveUpdateDestroyAPIView):
if changed:
raise PermissionDenied('Cannot change %s' % ', '.join(changed.keys()))
new_password = request.DATA.get('password', '')
if can_change and new_password:
obj.set_password(new_password)
obj.save()
class CredentialList(ListAPIView):
model = Credential