Merge branch 'bug/super-user-creation' into 'dev'

Fix bug where SU status wouldn't stick on creation

See merge request crafty-controller/crafty-4!410
This commit is contained in:
Iain Powrie 2022-07-27 18:17:02 +00:00
commit b20e303932
2 changed files with 7 additions and 14 deletions

View File

@ -4,7 +4,7 @@
### New features ### New features
TBD TBD
### Bug fixes ### Bug fixes
TBD - Fix SU status not sticking on user creation ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/410))
### Tweaks ### Tweaks
TBD TBD
### Lang ### Lang

View File

@ -1878,15 +1878,12 @@ class PanelHandler(BaseHandler):
# We don't want that. Automatically make them stay super user # We don't want that. Automatically make them stay super user
# since we know they are. # since we know they are.
if str(exec_user["user_id"]) != str(user_id): if str(exec_user["user_id"]) != str(user_id):
superuser = bleach.clean(self.get_argument("superuser", "0")) superuser = int(bleach.clean(self.get_argument("superuser", "0")))
else: else:
superuser = "1" superuser = 1
else: else:
superuser = "0" superuser = 0
if superuser == "1":
superuser = True
else:
superuser = False
if not exec_user["superuser"]: if not exec_user["superuser"]:
if username is None or username == "": if username is None or username == "":
self.redirect("/panel/error?error=Invalid username") self.redirect("/panel/error?error=Invalid username")
@ -2062,13 +2059,9 @@ class PanelHandler(BaseHandler):
) )
# We don't want a non-super user to be able to create a super user. # We don't want a non-super user to be able to create a super user.
if superuser: if superuser:
new_superuser = bleach.clean(self.get_argument("superuser", "0")) new_superuser = int(bleach.clean(self.get_argument("superuser", "0")))
else: else:
new_superuser = "0" new_superuser = 0
if superuser == "1":
new_superuser = True
else:
new_superuser = False
if EnumPermissionsCrafty.USER_CONFIG not in exec_user_crafty_permissions: if EnumPermissionsCrafty.USER_CONFIG not in exec_user_crafty_permissions:
self.redirect( self.redirect(