Skip to content

Commit

Permalink
toggle admin attribute properly during put. rockstor#688
Browse files Browse the repository at this point in the history
  • Loading branch information
schakrava committed Jul 6, 2015
1 parent a768c5b commit fe2dc07
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/rockstor/storageadmin/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ def post(self, request):

invar = self._validate_input(request)
# Check that a django user with the same name does not exist
e_msg = ('user: %s already exists. Please choose a different'
e_msg = ('User(%s) already exists. Please choose a different'
' username' % invar['username'])
if (DjangoUser.objects.filter(
username=invar['username']).exists()):
username=invar['username']).exists() or
User.objects.filter(username=invar['username']).exists()):
handle_exception(Exception(e_msg), request)
users = combined_users()
groups = combined_groups()
Expand Down Expand Up @@ -157,7 +158,6 @@ def post(self, request):
admin=True)
admin_group.save()
invar['group'] = admin_group
invar['admin'] = True
suser = User(**invar)
suser.full_clean()
suser.save()
Expand Down Expand Up @@ -204,10 +204,12 @@ def put(self, request, username):
elif (new_pw is not None):
u.user.set_password(new_pw)
u.user.save()
elif (u.user is not None):
auser = u.user
u.user = None
auser.delete()
else:
u.admin = admin
if (u.user is not None):
auser = u.user
u.user = None
auser.delete()

u.public_key = public_key
if (email is not None and email != ''):
Expand Down

0 comments on commit fe2dc07

Please sign in to comment.