mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 23:51:09 +03:00
Make sure we clear owned-credentials when we delete a user
This commit is contained in:
parent
7d6cf7e2d0
commit
04eeffe2a7
@ -772,6 +772,15 @@ class UserDetail(RetrieveUpdateDestroyAPIView):
|
||||
if changed:
|
||||
raise PermissionDenied('Cannot change %s' % ', '.join(changed.keys()))
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
obj = User.objects.get(pk=kwargs['pk'])
|
||||
can_delete = request.user.can_access(User, 'delete', obj)
|
||||
if not can_delete:
|
||||
raise PermissionDenied('Cannot delete user')
|
||||
for own_credential in Credential.objects.filter(user=obj):
|
||||
own_credential.mark_inactive()
|
||||
return super(UserDetail, self).destroy(request, *args, **kwargs)
|
||||
|
||||
class CredentialList(ListCreateAPIView):
|
||||
|
||||
model = Credential
|
||||
|
Loading…
Reference in New Issue
Block a user