Restrict removal of last admin user

- Don't allow disabling the only available admin account.
- Don't allow deletion of the only available admin account.
- Don't allow removing admin privileges of the only available admin account.

Signed-off-by: Hemanth Kumar Veeranki <hems.india1997@gmail.com>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
Hemanth Kumar Veeranki authored and Joseph Nuthalapati committed 2018-06-21 20:09:02 +05:30
1 parent b605c9da8a
commit b9963a45cd
6 files changed
+91 -7

No files matched your search

+12
View File
@@ -105,3 +105,15 @@ def remove_group(group):
def register_group(group):
groups[group[0]] = group[1]
def get_last_admin_user():
""" Check if there is only one admin user
if yes return its name else return None
"""
admin_users = actions.superuser_run('users',
['get-group-users','admin']
).strip().split('\n')
if len(admin_users) > 1:
return None
return admin_users[0]