Fix minor bugs in super user activation. Add 'are you sure' to delete user

This commit is contained in:
Andrew 2022-01-09 23:16:11 -05:00
parent 3546d50142
commit db6a886e0f
3 changed files with 35 additions and 2 deletions

View File

@ -448,6 +448,10 @@ class PanelHandler(BaseHandler):
page_data['quantity_server'] = self.controller.crafty_perms.list_all_crafty_permissions_quantity_limits()
page_data['languages'] = []
page_data['languages'].append(self.controller.users.get_user_lang_by_id(exec_user_id))
if exec_user['superuser']:
page_data['super-disabled'] = ''
else:
page_data['super-disabled'] = 'disabled'
for file in os.listdir(os.path.join(helper.root_dir, 'app', 'translations')):
if file.endswith('.json'):
if file != str(page_data['languages'][0] + '.json'):
@ -1012,7 +1016,7 @@ class PanelHandler(BaseHandler):
else:
server_quantity[permission.name] = 0
user_id = self.controller.users.add_user(username, password=password0, email=email, enabled=enabled)
user_id = self.controller.users.add_user(username, password=password0, email=email, enabled=enabled, superuser=superuser)
user_data = {
"roles": roles,
'lang': lang

View File

@ -229,7 +229,7 @@
<a class="btn btn-sm btn-danger disabled"><i class="fas fa-trash"></i> Delete User</a><br />
<small>You cannot delete a superuser</small>
{% else %}
<a href="/panel/remove_user?id={{ data['user']['user_id'] }}" class="btn btn-sm btn-danger"><i class="fas fa-trash"></i> Delete User</a>
<button class="btn btn-sm btn-danger delete-user"><i class="fas fa-trash"></i> Delete User</a>
{% end %}
</div>
@ -250,6 +250,31 @@
{% block js %}
<script>
$( ".delete-user" ).click(function() {
var file_to_del = $(this).data("file");
console.log("User to delete is {{ data['user']['username'] }}");
bootbox.confirm({
title: "{% raw translate('usersConfig', 'deleteUser', data['lang']) %}"+"{{ data['user']['username'] }}",
message: "{{ translate('usersConfig', 'confirmDelete', data['lang']) }}",
buttons: {
cancel: {
label: '<i class="fas fa-times"></i> {{ translate("serverBackups", "cancel", data['lang']) }}'
},
confirm: {
className: 'btn-outline-danger',
label: '<i class="fas fa-check"></i> {{ translate("serverBackups", "confirm", data['lang']) }}'
}
},
callback: function (result) {
console.log(result);
if (result == true) {
location.href="/panel/remove_user?id={{ data['user']['user_id'] }}";
}
}
});
});
function superConfirm() {
if (document.getElementById('superuser').checked){

View File

@ -76,6 +76,10 @@
"clickRoot": "Click here to select Root Dir",
"explainRoot": "Please click the button below to select your server's root dir inside of the archive"
},
"usersConfig":{
"deleteUser": "Delete user: ",
"confirmDelete": "Are you sure you want to delete this user? This action is irreversible."
},
"dashboard": {
"dashboard": "Dashboard",
"memUsage": "Memory Usage",