diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 6ed568a02f..c5e17d1bcc 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -1175,7 +1175,11 @@ if ($config['double_auth_enabled'] && check_acl($config['id_user'], 0, 'PM')) { || ($config['double_auth_enabled'] == '' && $double_auth_enabled) || check_acl($config['id_user'], 0, 'PM') ) { - $double_authentication .= html_print_checkbox_switch('double_auth', 1, $double_auth_enabled, true); + if ($new_user === false) { + $double_authentication .= html_print_checkbox_switch('double_auth', 1, $double_auth_enabled, true); + } else { + $double_authentication .= ui_print_help_tip(__('User must be created before activating double authentication.'), true); + } } // Dialog. @@ -1581,6 +1585,7 @@ console.log(userID); data: { page: 'include/ajax/double_auth.ajax', id_user: userID, + id_user_auth: userID, get_double_auth_data_page: 1, FA_forced: 1, containerID: $dialogContainer.prop('id') @@ -1637,6 +1642,8 @@ function show_double_auth_activation () { var $loadingSpinner = $("/images/spinner.gif\" />"); var $dialogContainer = $("div#dialog-double_auth-container"); + // Uncheck until completed successfully. + $("input#checkbox-double_auth").prop( "checked", false ); $dialogContainer.html($loadingSpinner); @@ -1648,6 +1655,7 @@ function show_double_auth_activation () { data: { page: 'include/ajax/double_auth.ajax', id_user: userID, + id_user_auth: userID, FA_forced: 1, get_double_auth_info_page: 1, containerID: $dialogContainer.prop('id') @@ -1690,8 +1698,6 @@ function show_double_auth_activation () { request.abort(); // Remove the contained html $dialogContainer.empty(); - - document.location.reload(); } }) .show(); @@ -1705,6 +1711,9 @@ function show_double_auth_deactivation () { var message = "

'.__('The double authentication will be deactivated'); ?>

"; var $button = $("\" />"); + // Prevent switch deactivaction until proceess is done + $("input#checkbox-double_auth").prop( "checked", true ); + $dialogContainer .empty() @@ -1739,6 +1748,7 @@ function show_double_auth_deactivation () { } else if (data) { $dialogContainer.html("
'.__('The double autentication was deactivated successfully').'
'; ?>"); + $("input#checkbox-double_auth").prop( "checked", false ); } else { $dialogContainer.html("
'.__('There was an error deactivating the double autentication').'
'; ?>"); @@ -1769,7 +1779,6 @@ function show_double_auth_deactivation () { // Remove the contained html $dialogContainer.empty(); - document.location.reload(); } }) .show(); diff --git a/pandora_console/include/ajax/double_auth.ajax.php b/pandora_console/include/ajax/double_auth.ajax.php index b5c816c6b3..ebe45a3894 100644 --- a/pandora_console/include/ajax/double_auth.ajax.php +++ b/pandora_console/include/ajax/double_auth.ajax.php @@ -18,6 +18,8 @@ check_login(); // Security check $id_user = (string) get_parameter('id_user'); $FA_forced = (int) get_parameter('FA_forced'); +$id_user_auth = (string) get_parameter('id_user_auth', $config['id_user']); + if ($id_user !== $config['id_user'] && $FA_forced != 1) { db_pandora_audit( @@ -70,12 +72,12 @@ if ($validate_double_auth_code) { if ($result && $save) { // Delete the actual value (if exists) - $where = ['id_user' => $id_user]; + $where = ['id_user' => $id_user_auth]; db_process_sql_delete('tuser_double_auth', $where); // Insert the new value $values = [ - 'id_user' => $id_user, + 'id_user' => $id_user_auth, 'secret' => $secret, ]; $result = (bool) db_process_sql_insert('tuser_double_auth', $values); @@ -152,12 +154,15 @@ if ($get_double_auth_data_page) { ob_clean(); ?> + +