Skip to content

Commit

Permalink
Fixing Issue #4540 - Template Account Editing
Browse files Browse the repository at this point in the history
Administrators can cause issues when editing a template account
  • Loading branch information
TheWitness committed Feb 3, 2022
1 parent b519f56 commit be7960c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Cacti CHANGELOG
-issue#4530: Cacti's Reporting Interface is NOT Usable on Large Systems
-issue#4536: After authenticating via Web Basic Authentication, user always mapped as guest.
-issue#4539: Broken handling of plugin dependencies in 1.2.19
-issue#4540: Administrators can cause issues when editing a template account
-feature: Expose hidden Language Translation setting l10n_language_handler
-feature: Allow a Device to be a part of a Report outside of a Tree
-feature: Allow Basic Authentication to display customer login failed message
Expand Down
25 changes: 23 additions & 2 deletions user_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,20 @@ function form_save() {
$save['show_preview'] = form_input_validate(get_nfilter_request_var('show_preview', ''), 'show_preview', '', true, 3);
$save['graph_settings'] = form_input_validate(get_nfilter_request_var('graph_settings', ''), 'graph_settings', '', true, 3);
$save['login_opts'] = form_input_validate(get_nfilter_request_var('login_opts'), 'login_opts', '', true, 3);
$save['realm'] = get_nfilter_request_var('realm', 0);
$save['password_history'] = $history;
$save['enabled'] = form_input_validate(get_nfilter_request_var('enabled', ''), 'enabled', '', true, 3);

/* force enable/disable on template accounts */
if (read_config_option('admin_user') == get_nfilter_request_var('id')) {
$save['enabled'] = 'on';
$save['realm'] = get_nfilter_request_var('realm', 0);
} elseif (is_template_account(get_nfilter_request_var('id'))) {
$save['enabled'] = '';
$save['realm'] = 0;
} else {
$save['enabled'] = form_input_validate(get_nfilter_request_var('enabled', ''), 'enabled', '', true, 3);
$save['realm'] = get_nfilter_request_var('realm', 0);
}

$save['email_address'] = form_input_validate(get_nfilter_request_var('email_address', ''), 'email_address', '', true, 3);
$save['locked'] = form_input_validate(get_nfilter_request_var('locked', ''), 'locked', '', true, 3);
$save['reset_perms'] = mt_rand();
Expand Down Expand Up @@ -2045,6 +2056,7 @@ function user_edit() {
<script type='text/javascript'>

var minChars=<?php print read_config_option('secpass_minlen');?>;
var templateAccount=<?php print is_template_account(get_filter_request_var('id')) ? 'true':'false';?>;

function changeRealm() {
if ($('#realm').val() != 0) {
Expand Down Expand Up @@ -2141,6 +2153,15 @@ function checkPasswordConfirm() {
}
}
});

if (templateAccount == true) {
$('#realm').prop('disabled', true);
$('#enabled').prop('disabled', true);

if ($('#realm').selectmenu('instance')) {
$('#realm').selectmenu('disable');
}
}
});

</script>
Expand Down

0 comments on commit be7960c

Please sign in to comment.