mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
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:
1 parent
b605c9da8a
commit
b9963a45cd
6 files changed
+91
-7
No files matched your search
@@ -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]
|
||||
Reference in new issue
Block a user