mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-26 03:19:05 +02:00
Double authentication active
This commit is contained in:
parent
1de571fa66
commit
e42c4575d5
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User creation / update.
|
* User creation / update.
|
||||||
*
|
*
|
||||||
@ -28,7 +29,7 @@
|
|||||||
|
|
||||||
// Load global vars.
|
// Load global vars.
|
||||||
global $config;
|
global $config;
|
||||||
// hd($_REQUEST, true); //TODO. For testing purposes.
|
|
||||||
check_login();
|
check_login();
|
||||||
|
|
||||||
require_once $config['homedir'].'/vendor/autoload.php';
|
require_once $config['homedir'].'/vendor/autoload.php';
|
||||||
@ -1410,7 +1411,7 @@ if (enterprise_installed() && is_metaconsole() === true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO review help tips on meta.
|
// TODO review help tips on meta.
|
||||||
$meta_access = '<div class="label_select"><p class="edit_user_labels">'.__('Metaconsole access').' './* ui_print_help_icon('meta_access', true). */'</p>';
|
$meta_access = '<div class="label_select"><p class="edit_user_labels">'.__('Metaconsole access').' './* ui_print_help_icon('meta_access', true). */ '</p>';
|
||||||
$metaconsole_accesses = [
|
$metaconsole_accesses = [
|
||||||
'basic' => __('Basic'),
|
'basic' => __('Basic'),
|
||||||
'advanced' => __('Advanced'),
|
'advanced' => __('Advanced'),
|
||||||
@ -1531,27 +1532,50 @@ if (isset($config['ehorus_user_level_conf']) === true && (bool) $config['ehorus_
|
|||||||
$ehorus .= '</div>';
|
$ehorus .= '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $id);
|
// Double authentication.
|
||||||
|
$doubleAuthElementsContent = [];
|
||||||
if (isset($config['double_auth_enabled']) === true && (bool) ($config['double_auth_enabled']) === true && check_acl($config['id_user'], 0, 'PM')) {
|
if (isset($config['double_auth_enabled']) === true && (bool) ($config['double_auth_enabled']) === true && check_acl($config['id_user'], 0, 'PM')) {
|
||||||
$double_authentication = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Double authentication').'</p>';
|
// Know if Double Auth is enabled.
|
||||||
|
$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $id);
|
||||||
|
// Double authentication elements.
|
||||||
|
$doubleAuthElementsSubContent = [];
|
||||||
|
// Caption.
|
||||||
|
$doubleAuthElementsSubContent[] = '<span>'.__('Double authentication').'</span>';
|
||||||
|
// Switch.
|
||||||
if (($config['2FA_all_users'] == '' && !$double_auth_enabled)
|
if (($config['2FA_all_users'] == '' && !$double_auth_enabled)
|
||||||
|| ($config['double_auth_enabled'] == '' && $double_auth_enabled)
|
|| ($config['double_auth_enabled'] == '' && $double_auth_enabled)
|
||||||
|| check_acl($config['id_user'], 0, 'PM')
|
|| check_acl($config['id_user'], 0, 'PM')
|
||||||
) {
|
) {
|
||||||
if ($new_user === false) {
|
if ($new_user === false) {
|
||||||
$double_authentication .= html_print_checkbox_switch('double_auth', 1, $double_auth_enabled, true);
|
$doubleAuthElementsSubContent[] = html_print_checkbox_switch('double_auth', 1, $double_auth_enabled, true);
|
||||||
} else {
|
} else {
|
||||||
$double_authentication .= ui_print_help_tip(__('User must be created before activating double authentication.'), true);
|
$doubleAuthElementsSubContent[] = ui_print_help_tip(__('User must be created before activating double authentication.'), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Control for show.
|
||||||
|
$doubleAuthElementsContent[] = html_print_div(
|
||||||
|
[
|
||||||
|
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
|
||||||
|
'class' => 'margin-top-10',
|
||||||
|
'content' => implode('', $doubleAuthElementsSubContent),
|
||||||
|
],
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
// Dialog.
|
// Dialog.
|
||||||
$double_authentication .= '<div id="dialog-double_auth" class="invisible"><div id="dialog-double_auth-container"></div></div>';
|
$doubleAuthElementsContent[] = html_print_div(
|
||||||
|
[
|
||||||
|
'id' => 'dialog-double_auth',
|
||||||
|
'class' => 'invisible',
|
||||||
|
'content' => html_print_div(['id' => 'dialog-double_auth-container'], true),
|
||||||
|
],
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($double_auth_enabled && $config['double_auth_enabled'] && $config['2FA_all_users'] != '') {
|
if ($double_auth_enabled === true && (bool) $config['double_auth_enabled'] === true && empty($config['2FA_all_users']) === false) {
|
||||||
$double_authentication .= html_print_button(
|
$doubleAuthElementsContent[] = html_print_button(
|
||||||
__('Show information'),
|
__('Show information'),
|
||||||
'show_info',
|
'show_info',
|
||||||
false,
|
false,
|
||||||
@ -1561,9 +1585,29 @@ if ($double_auth_enabled && $config['double_auth_enabled'] && $config['2FA_all_u
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($double_authentication)) {
|
$doubleAuthentication = html_print_div(['content' => implode('', $doubleAuthElementsContent)], true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (isset($double_authentication)) {
|
||||||
$double_authentication .= '</div>';
|
$double_authentication .= '</div>';
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1870,7 +1914,7 @@ if (is_metaconsole() === false) {
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
$(document).ready (function () {
|
$(document).ready(function() {
|
||||||
// Set up the picker to update target timezone and country select lists.
|
// Set up the picker to update target timezone and country select lists.
|
||||||
$('#timezone-image').timezonePicker({
|
$('#timezone-image').timezonePicker({
|
||||||
target: '#timezone',
|
target: '#timezone',
|
||||||
@ -1892,9 +1936,9 @@ if (is_metaconsole() === false) {
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var json_profile = $('#hidden-json_profile');
|
var json_profile = $('#hidden-json_profile');
|
||||||
/* <![CDATA[ */
|
/* <![CDATA[ */
|
||||||
$(document).ready (function () {
|
$(document).ready(function() {
|
||||||
|
|
||||||
// Set up the picker to update target timezone and country select lists.
|
// Set up the picker to update target timezone and country select lists.
|
||||||
$('#timezone-image').timezonePicker({
|
$('#timezone-image').timezonePicker({
|
||||||
@ -1906,8 +1950,8 @@ $(document).ready (function () {
|
|||||||
$('#timezone-image').timezonePicker('detectLocation');
|
$('#timezone-image').timezonePicker('detectLocation');
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#right_autorefreshlist").click (function () {
|
$("#right_autorefreshlist").click(function() {
|
||||||
jQuery.each($("select[name='autorefresh_list_out[]'] option:selected"), function (key, value) {
|
jQuery.each($("select[name='autorefresh_list_out[]'] option:selected"), function(key, value) {
|
||||||
imodule_name = $(value).html();
|
imodule_name = $(value).html();
|
||||||
if (imodule_name != <?php echo "'".__('None')."'"; ?>) {
|
if (imodule_name != <?php echo "'".__('None')."'"; ?>) {
|
||||||
id_imodule = $(value).attr('value');
|
id_imodule = $(value).attr('value');
|
||||||
@ -1915,15 +1959,15 @@ $(document).ready (function () {
|
|||||||
$("#autorefresh_list_out").find("option[value='" + id_imodule + "']").remove();
|
$("#autorefresh_list_out").find("option[value='" + id_imodule + "']").remove();
|
||||||
$("#autorefresh_list").find("option[value='']").remove();
|
$("#autorefresh_list").find("option[value='']").remove();
|
||||||
$("#autorefresh_list").find("option[value='0']").remove();
|
$("#autorefresh_list").find("option[value='0']").remove();
|
||||||
if($("#autorefresh_list_out option").length == 0) {
|
if ($("#autorefresh_list_out option").length == 0) {
|
||||||
$("select[name='autorefresh_list_out[]']").append($("<option></option>").val('').html('<i><?php echo __('None'); ?></i>'));
|
$("select[name='autorefresh_list_out[]']").append($("<option></option>").val('').html('<i><?php echo __('None'); ?></i>'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#left_autorefreshlist").click (function () {
|
$("#left_autorefreshlist").click(function() {
|
||||||
jQuery.each($("select[name='autorefresh_list[]'] option:selected"), function (key, value) {
|
jQuery.each($("select[name='autorefresh_list[]'] option:selected"), function(key, value) {
|
||||||
imodule_name = $(value).html();
|
imodule_name = $(value).html();
|
||||||
if (imodule_name != <?php echo "'".__('None')."'"; ?>) {
|
if (imodule_name != <?php echo "'".__('None')."'"; ?>) {
|
||||||
id_imodule = $(value).attr('value');
|
id_imodule = $(value).attr('value');
|
||||||
@ -1931,14 +1975,14 @@ $(document).ready (function () {
|
|||||||
$("#autorefresh_list_out").find("option[value='']").remove();
|
$("#autorefresh_list_out").find("option[value='']").remove();
|
||||||
$("select[name='autorefresh_list_out[]']").append($("<option><option>").val(id_imodule).html('<i>' + imodule_name + '</i>'));
|
$("select[name='autorefresh_list_out[]']").append($("<option><option>").val(id_imodule).html('<i>' + imodule_name + '</i>'));
|
||||||
$("#autorefresh_list_out option").last().remove();
|
$("#autorefresh_list_out option").last().remove();
|
||||||
if($("#autorefresh_list option").length == 0) {
|
if ($("#autorefresh_list option").length == 0) {
|
||||||
$("select[name='autorefresh_list[]']").append($("<option></option>").val('').html('<i><?php echo __('None'); ?></i>'));
|
$("select[name='autorefresh_list[]']").append($("<option></option>").val('').html('<i><?php echo __('None'); ?></i>'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("input#checkbox-double_auth").change(function (e) {
|
$("input#checkbox-double_auth").change(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
show_double_auth_activation();
|
show_double_auth_activation();
|
||||||
@ -1962,7 +2006,7 @@ $(document).ready (function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#checkbox-metaconsole_agents_manager').change(function() {
|
$('#checkbox-metaconsole_agents_manager').change(function() {
|
||||||
if($('#checkbox-metaconsole_agents_manager').prop('checked')) {
|
if ($('#checkbox-metaconsole_agents_manager').prop('checked')) {
|
||||||
$('#metaconsole_assigned_server_div').show();
|
$('#metaconsole_assigned_server_div').show();
|
||||||
} else {
|
} else {
|
||||||
$('#metaconsole_assigned_server_div').hide();
|
$('#metaconsole_assigned_server_div').hide();
|
||||||
@ -1973,7 +2017,7 @@ $(document).ready (function () {
|
|||||||
$('#checkbox-metaconsole_agents_manager').trigger('change');
|
$('#checkbox-metaconsole_agents_manager').trigger('change');
|
||||||
|
|
||||||
show_data_section();
|
show_data_section();
|
||||||
$('#checkbox-ehorus_user_level_enabled').change(function () {
|
$('#checkbox-ehorus_user_level_enabled').change(function() {
|
||||||
switch_ehorus_conf();
|
switch_ehorus_conf();
|
||||||
});
|
});
|
||||||
$('#checkbox-ehorus_user_level_enabled').trigger('change');
|
$('#checkbox-ehorus_user_level_enabled').trigger('change');
|
||||||
@ -1998,7 +2042,7 @@ $(document).ready (function () {
|
|||||||
var group_text = $('#assign_group option:selected').text();
|
var group_text = $('#assign_group option:selected').text();
|
||||||
var tags = $('#assign_tags').val();
|
var tags = $('#assign_tags').val();
|
||||||
var tags_text = $('#assign_tags option:selected').toArray().map(item => item.text).join();
|
var tags_text = $('#assign_tags option:selected').toArray().map(item => item.text).join();
|
||||||
if ( $('#checkbox-no_hierarchy').is(':checked')) {
|
if ($('#checkbox-no_hierarchy').is(':checked')) {
|
||||||
var hierarchy = 1;
|
var hierarchy = 1;
|
||||||
var hierarchy_text = '<?php echo __('yes'); ?>';
|
var hierarchy_text = '<?php echo __('yes'); ?>';
|
||||||
} else {
|
} else {
|
||||||
@ -2049,7 +2093,7 @@ $(document).ready (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('input:image[name="add"]').click(function (e) {
|
$('input:image[name="add"]').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (id_user.length === 0) {
|
if (id_user.length === 0) {
|
||||||
@ -2063,14 +2107,14 @@ $(document).ready (function () {
|
|||||||
params.push("group_id=" + $('#assign_group').val());
|
params.push("group_id=" + $('#assign_group').val());
|
||||||
params.push("user_id=" + id_user);
|
params.push("user_id=" + id_user);
|
||||||
params.push("page=godmode/users/configure_user");
|
params.push("page=godmode/users/configure_user");
|
||||||
jQuery.ajax ({
|
jQuery.ajax({
|
||||||
data: params.join("&"),
|
data: params.join("&"),
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
form: this.form,
|
form: this.form,
|
||||||
url: action="<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
url: action = "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
success: function (data) {
|
success: function(data) {
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
alert('<?php echo __('This profile is already defined'); ?>');
|
alert('<?php echo __('This profile is already defined'); ?>');
|
||||||
} else {
|
} else {
|
||||||
@ -2080,9 +2124,9 @@ $(document).ready (function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('input:image[name="del"]').click(function (e) {
|
$('input:image[name="del"]').click(function(e) {
|
||||||
if($(json_profile).length > 0) return;
|
if ($(json_profile).length > 0) return;
|
||||||
if (!confirm ('Are you sure?')) return;
|
if (!confirm('Are you sure?')) return;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var rows = $("#table_profiles tr").length;
|
var rows = $("#table_profiles tr").length;
|
||||||
if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') {
|
if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') {
|
||||||
@ -2100,11 +2144,11 @@ $(document).ready (function () {
|
|||||||
params.push("id_user=" + id_user);
|
params.push("id_user=" + id_user);
|
||||||
params.push("id_user_profile=" + id_user_profile);
|
params.push("id_user_profile=" + id_user_profile);
|
||||||
params.push("page=godmode/users/configure_user");
|
params.push("page=godmode/users/configure_user");
|
||||||
jQuery.ajax ({
|
jQuery.ajax({
|
||||||
data: params.join ("&"),
|
data: params.join("&"),
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: action="<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
url: action = "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||||
success: function (data) {
|
success: function(data) {
|
||||||
row.remove();
|
row.remove();
|
||||||
var rows = $("#table_profiles tr").length;
|
var rows = $("#table_profiles tr").length;
|
||||||
|
|
||||||
@ -2137,16 +2181,16 @@ $(document).ready (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#submit-crtbutton').click(function (e) {
|
$('#submit-crtbutton').click(function(e) {
|
||||||
checkProfiles(e);
|
checkProfiles(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#submit-uptbutton').click(function (e) {
|
$('#submit-uptbutton').click(function(e) {
|
||||||
checkProfiles(e);
|
checkProfiles(e);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function delete_profile(event, btn) {
|
function delete_profile(event, btn) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var row = btn.parentNode.parentNode;
|
var row = btn.parentNode.parentNode;
|
||||||
var position = row.rowIndex;
|
var position = row.rowIndex;
|
||||||
@ -2157,39 +2201,36 @@ function delete_profile(event, btn) {
|
|||||||
|
|
||||||
var position_offset = <?php echo (is_metaconsole() === true) ? 2 : 1; ?>;
|
var position_offset = <?php echo (is_metaconsole() === true) ? 2 : 1; ?>;
|
||||||
|
|
||||||
test.splice(position-position_offset, 1);
|
test.splice(position - position_offset, 1);
|
||||||
json_profile.val(JSON.stringify(test));
|
json_profile.val(JSON.stringify(test));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_data_section () {
|
function show_data_section() {
|
||||||
var $section = $("#section").val();
|
var $section = $("#section").val();
|
||||||
var $allElements = $('div[id^="custom_home_screen_"]');
|
var $allElements = $('div[id^="custom_home_screen_"]');
|
||||||
var $elementSelected = $('div[id="custom_home_screen_'+$section+'"]');
|
var $elementSelected = $('div[id="custom_home_screen_' + $section + '"]');
|
||||||
// Hide all elements.
|
// Hide all elements.
|
||||||
$allElements.each(function(){
|
$allElements.each(function() {
|
||||||
$(this).addClass('invisible');
|
$(this).addClass('invisible');
|
||||||
$(this).children().addClass('invisible');
|
$(this).children().addClass('invisible');
|
||||||
})
|
})
|
||||||
// Show only the selected.
|
// Show only the selected.
|
||||||
$elementSelected.removeClass('invisible');
|
$elementSelected.removeClass('invisible');
|
||||||
$elementSelected.children().removeClass('invisible');
|
$elementSelected.children().removeClass('invisible');
|
||||||
}
|
}
|
||||||
|
|
||||||
function switch_ehorus_conf()
|
function switch_ehorus_conf() {
|
||||||
{
|
if (!$('#checkbox-ehorus_user_level_enabled').prop('checked')) {
|
||||||
if(!$('#checkbox-ehorus_user_level_enabled').prop('checked'))
|
|
||||||
{
|
|
||||||
$(".user_edit_ehorus_outer").hide();
|
$(".user_edit_ehorus_outer").hide();
|
||||||
|
|
||||||
}else
|
} else {
|
||||||
{
|
|
||||||
$(".user_edit_ehorus_outer").show();
|
$(".user_edit_ehorus_outer").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_double_auth_info () {
|
function show_double_auth_info() {
|
||||||
var userID = '<?php echo io_safe_output($id); ?>';
|
var userID = '<?php echo io_safe_output($id); ?>';
|
||||||
|
|
||||||
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
|
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
|
||||||
@ -2220,8 +2261,7 @@ function show_double_auth_info () {
|
|||||||
// data is a number, convert it to integer to do the compare
|
// data is a number, convert it to integer to do the compare
|
||||||
else if (Number(data) === -1) {
|
else if (Number(data) === -1) {
|
||||||
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
|
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Error').'</div></b>'; ?>");
|
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Error').'</div></b>'; ?>");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2231,7 +2271,7 @@ function show_double_auth_info () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("div#dialog-double_auth")
|
$("div#dialog-double_auth")
|
||||||
.css('display','block')
|
.css('display', 'block')
|
||||||
.append($dialogContainer)
|
.append($dialogContainer)
|
||||||
.dialog({
|
.dialog({
|
||||||
resizable: true,
|
resizable: true,
|
||||||
@ -2254,15 +2294,15 @@ function show_double_auth_info () {
|
|||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_double_auth_activation () {
|
function show_double_auth_activation() {
|
||||||
var userID = '<?php echo io_safe_output($id); ?>';
|
var userID = '<?php echo io_safe_output($id); ?>';
|
||||||
|
|
||||||
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
|
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
|
||||||
var $dialogContainer = $("div#dialog-double_auth-container");
|
var $dialogContainer = $("div#dialog-double_auth-container");
|
||||||
// Uncheck until completed successfully.
|
// Uncheck until completed successfully.
|
||||||
$("input#checkbox-double_auth").prop( "checked", false );
|
$("input#checkbox-double_auth").prop("checked", false);
|
||||||
|
|
||||||
$dialogContainer.html($loadingSpinner);
|
$dialogContainer.html($loadingSpinner);
|
||||||
|
|
||||||
@ -2290,8 +2330,7 @@ function show_double_auth_activation () {
|
|||||||
// data is a number, convert it to integer to do the compare
|
// data is a number, convert it to integer to do the compare
|
||||||
else if (Number(data) === -1) {
|
else if (Number(data) === -1) {
|
||||||
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
|
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Error').'</div></b>'; ?>");
|
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Error').'</div></b>'; ?>");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2320,9 +2359,9 @@ function show_double_auth_activation () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_double_auth_deactivation () {
|
function show_double_auth_deactivation() {
|
||||||
var userID = '<?php echo io_safe_output($id); ?>';
|
var userID = '<?php echo io_safe_output($id); ?>';
|
||||||
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
|
var $loadingSpinner = $("<img src=\"<?php echo $config['homeurl']; ?>/images/spinner.gif\" />");
|
||||||
var $dialogContainer = $("div#dialog-double_auth-container");
|
var $dialogContainer = $("div#dialog-double_auth-container");
|
||||||
@ -2330,7 +2369,7 @@ function show_double_auth_deactivation () {
|
|||||||
var message = "<p><?php echo __('Are you sure?').'<br>'.__('The double authentication will be deactivated'); ?></p>";
|
var message = "<p><?php echo __('Are you sure?').'<br>'.__('The double authentication will be deactivated'); ?></p>";
|
||||||
var $button = $("<input type=\"button\" value=\"<?php echo __('Deactivate'); ?>\" />");
|
var $button = $("<input type=\"button\" value=\"<?php echo __('Deactivate'); ?>\" />");
|
||||||
// Prevent switch deactivaction until proceess is done
|
// Prevent switch deactivaction until proceess is done
|
||||||
$("input#checkbox-double_auth").prop( "checked", true );
|
$("input#checkbox-double_auth").prop("checked", true);
|
||||||
|
|
||||||
|
|
||||||
$dialogContainer
|
$dialogContainer
|
||||||
@ -2362,12 +2401,10 @@ function show_double_auth_deactivation () {
|
|||||||
success: function(data, textStatus, xhr) {
|
success: function(data, textStatus, xhr) {
|
||||||
if (data === -1) {
|
if (data === -1) {
|
||||||
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
|
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('Authentication error').'</div></b>'; ?>");
|
||||||
}
|
} else if (data) {
|
||||||
else if (data) {
|
|
||||||
$dialogContainer.html("<?php echo '<b><div class=\"green\">'.__('The double autentication was deactivated successfully').'</div></b>'; ?>");
|
$dialogContainer.html("<?php echo '<b><div class=\"green\">'.__('The double autentication was deactivated successfully').'</div></b>'; ?>");
|
||||||
$("input#checkbox-double_auth").prop( "checked", false );
|
$("input#checkbox-double_auth").prop("checked", false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error deactivating the double autentication').'</div></b>'; ?>");
|
$dialogContainer.html("<?php echo '<b><div class=\"red\">'.__('There was an error deactivating the double autentication').'</div></b>'; ?>");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2399,8 +2436,8 @@ function show_double_auth_deactivation () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ]]> */
|
/* ]]> */
|
||||||
</script>
|
</script>
|
@ -220,6 +220,9 @@ $userManagementTable->data['fields_phone'][0] = html_print_input_text_extended(
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$userManagementTable->rowclass['captions_fields_admin_user'] = 'field_half_width w50p';
|
||||||
|
$userManagementTable->cellclass['captions_fields_admin_user'][0] = 'wrap';
|
||||||
|
$userManagementTable->data['captions_fields_admin_user'][0] = $doubleAuthentication;
|
||||||
if (users_is_admin() === true) {
|
if (users_is_admin() === true) {
|
||||||
$globalProfileContent = [];
|
$globalProfileContent = [];
|
||||||
$globalProfileContent[] = '<span>'.__('Administrator user').'</span>';
|
$globalProfileContent[] = '<span>'.__('Administrator user').'</span>';
|
||||||
@ -230,8 +233,8 @@ if (users_is_admin() === true) {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
$userManagementTable->rowclass['captions_fields_admin_user'] = 'field_half_width';
|
$userManagementTable->cellclass['captions_fields_admin_user'][1] = 'wrap';
|
||||||
$userManagementTable->data['captions_fields_admin_user'][0] = html_print_div(
|
$userManagementTable->data['captions_fields_admin_user'][1] = html_print_div(
|
||||||
[
|
[
|
||||||
'class' => 'margin-top-10',
|
'class' => 'margin-top-10',
|
||||||
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
|
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
|
||||||
|
@ -1,21 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
// Pandora FMS - http://pandorafms.com
|
|
||||||
// ==================================================
|
/**
|
||||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
* Double Authentication Ajax file.
|
||||||
// Please see http://pandorafms.org for full contribution list
|
*
|
||||||
// This program is free software; you can redistribute it and/or
|
* @category Users
|
||||||
// modify it under the terms of the GNU General Public License
|
* @package Pandora FMS
|
||||||
// as published by the Free Software Foundation for version 2.
|
* @subpackage Community
|
||||||
// This program is distributed in the hope that it will be useful,
|
* @version 1.0.0
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* @license See below
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
*
|
||||||
// GNU General Public License for more details.
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
|
||||||
|
* Please see http://pandorafms.org for full contribution list
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation for version 2.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Begin.
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// Login check
|
// Login check.
|
||||||
check_login();
|
check_login();
|
||||||
|
|
||||||
// Security check
|
// Security check.
|
||||||
$id_user = (string) get_parameter('id_user');
|
$id_user = (string) get_parameter('id_user');
|
||||||
$FA_forced = (int) get_parameter('FA_forced');
|
$FA_forced = (int) get_parameter('FA_forced');
|
||||||
$id_user_auth = (string) get_parameter('id_user_auth', $config['id_user']);
|
$id_user_auth = (string) get_parameter('id_user_auth', $config['id_user']);
|
||||||
@ -30,15 +48,15 @@ if ($id_user !== $config['id_user'] && $FA_forced != 1) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the class
|
// Load the class.
|
||||||
require_once $config['homedir'].'/include/auth/GAuth/Auth.php';
|
require_once $config['homedir'].'/include/auth/GAuth/Auth.php';
|
||||||
|
|
||||||
// Default lenght of the secret
|
// Default lenght of the secret.
|
||||||
$secret_lenght = 16;
|
$secret_lenght = 16;
|
||||||
// Default lenght of the code
|
// Default lenght of the code.
|
||||||
$code_lenght = 6;
|
$code_lenght = 6;
|
||||||
|
|
||||||
// Generate a new secret for the user
|
// Generate a new secret for the user.
|
||||||
$generate_double_auth_secret = (bool) get_parameter('generate_double_auth_secret');
|
$generate_double_auth_secret = (bool) get_parameter('generate_double_auth_secret');
|
||||||
if ($generate_double_auth_secret) {
|
if ($generate_double_auth_secret) {
|
||||||
$gAuth = new \GAuth\Auth();
|
$gAuth = new \GAuth\Auth();
|
||||||
@ -93,7 +111,7 @@ if ($validate_double_auth_code) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the provided secret to the user
|
// Set the provided secret to the user.
|
||||||
$save_double_auth_secret = (bool) get_parameter('save_double_auth_secret');
|
$save_double_auth_secret = (bool) get_parameter('save_double_auth_secret');
|
||||||
if ($save_double_auth_secret) {
|
if ($save_double_auth_secret) {
|
||||||
$result = false;
|
$result = false;
|
||||||
@ -101,10 +119,10 @@ if ($save_double_auth_secret) {
|
|||||||
$secret = (string) get_parameter('secret');
|
$secret = (string) get_parameter('secret');
|
||||||
|
|
||||||
if (strlen($secret) === $secret_lenght) {
|
if (strlen($secret) === $secret_lenght) {
|
||||||
// Delete the actual value (if exists)
|
// Delete the actual value (if exists).
|
||||||
$where = ['id_user' => $id_user];
|
$where = ['id_user' => $id_user];
|
||||||
db_process_sql_delete('tuser_double_auth', $where);
|
db_process_sql_delete('tuser_double_auth', $where);
|
||||||
// Insert the new value
|
// Insert the new value.
|
||||||
$values = [
|
$values = [
|
||||||
'id_user' => $id_user,
|
'id_user' => $id_user,
|
||||||
'secret' => $secret,
|
'secret' => $secret,
|
||||||
@ -116,12 +134,12 @@ if ($save_double_auth_secret) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable the double auth for the user
|
// Disable the double auth for the user.
|
||||||
$deactivate_double_auth = (bool) get_parameter('deactivate_double_auth');
|
$deactivate_double_auth = (bool) get_parameter('deactivate_double_auth');
|
||||||
if ($deactivate_double_auth) {
|
if ($deactivate_double_auth) {
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
||||||
// Delete the actual value (if exists)
|
// Delete the actual value (if exists).
|
||||||
$where = ['id_user' => $id_user];
|
$where = ['id_user' => $id_user];
|
||||||
$result = db_process_sql_delete('tuser_double_auth', $where);
|
$result = db_process_sql_delete('tuser_double_auth', $where);
|
||||||
|
|
||||||
@ -129,7 +147,7 @@ if ($deactivate_double_auth) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the info page to the container dialog
|
// Get the info page to the container dialog.
|
||||||
$get_double_auth_data_page = (bool) get_parameter('get_double_auth_data_page');
|
$get_double_auth_data_page = (bool) get_parameter('get_double_auth_data_page');
|
||||||
if ($get_double_auth_data_page) {
|
if ($get_double_auth_data_page) {
|
||||||
$secret = db_get_value('secret', 'tuser_double_auth', 'id_user', $id_user);
|
$secret = db_get_value('secret', 'tuser_double_auth', 'id_user', $id_user);
|
||||||
@ -146,7 +164,7 @@ if ($get_double_auth_data_page) {
|
|||||||
$html .= '</p>';
|
$html .= '</p>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
$html .= '<div class="center_align">';
|
$html .= '<div class="center_align">';
|
||||||
$html .= __('Code').": <b>$secret</b>";
|
$html .= __('Code').': <b>'.$secret.'</b>';
|
||||||
$html .= '<br>';
|
$html .= '<br>';
|
||||||
$html .= __('QR').': <br>';
|
$html .= __('QR').': <br>';
|
||||||
$html .= '<div id="qr-container"></div>';
|
$html .= '<div id="qr-container"></div>';
|
||||||
@ -161,7 +179,7 @@ if ($get_double_auth_data_page) {
|
|||||||
var secret = "<?php echo $secret; ?>";
|
var secret = "<?php echo $secret; ?>";
|
||||||
var id_user_auth = "<?php echo $id_user_auth; ?>";
|
var id_user_auth = "<?php echo $id_user_auth; ?>";
|
||||||
|
|
||||||
// QR code with the secret to add it to the app
|
// QR code with the secret to add it to the app.
|
||||||
paint_qrcode("otpauth://totp/"+id_user_auth+"?secret="+secret, $("div#qr-container").get(0), 200, 200);
|
paint_qrcode("otpauth://totp/"+id_user_auth+"?secret="+secret, $("div#qr-container").get(0), 200, 200);
|
||||||
|
|
||||||
$("div#qr-container").attr("title", "").find("canvas").remove();
|
$("div#qr-container").attr("title", "").find("canvas").remove();
|
||||||
@ -179,7 +197,7 @@ if ($get_double_auth_data_page) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the info page to the container dialog
|
// Get the info page to the container dialog.
|
||||||
$get_double_auth_info_page = (bool) get_parameter('get_double_auth_info_page');
|
$get_double_auth_info_page = (bool) get_parameter('get_double_auth_info_page');
|
||||||
if ($get_double_auth_info_page) {
|
if ($get_double_auth_info_page) {
|
||||||
$container_id = (string) get_parameter('containerID');
|
$container_id = (string) get_parameter('containerID');
|
||||||
@ -209,14 +227,14 @@ if ($get_double_auth_info_page) {
|
|||||||
ob_clean();
|
ob_clean();
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// Open the download page on click
|
// Open the download page on click.
|
||||||
$("input[name=\"google_authenticator_download\"]").click(function (e) {
|
$("#button-google_authenticator_download").click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
window.open("https://support.google.com/accounts/answer/1066447");
|
window.open("https://support.google.com/accounts/answer/1066447");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Change the container content with the generation page
|
// Change the container content with the generation page.
|
||||||
$("input[name=\"continue_to_generate\"]").click(function (e) {
|
$("#button-continue_to_generate").click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!confirm("<?php echo __('Are you installed the app yet?'); ?>")) {
|
if (!confirm("<?php echo __('Are you installed the app yet?'); ?>")) {
|
||||||
@ -268,7 +286,7 @@ if ($get_double_auth_info_page) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the page that generates a secret for the user
|
// Get the page that generates a secret for the user.
|
||||||
$get_double_auth_generation_page = (bool) get_parameter('get_double_auth_generation_page');
|
$get_double_auth_generation_page = (bool) get_parameter('get_double_auth_generation_page');
|
||||||
if ($get_double_auth_generation_page) {
|
if ($get_double_auth_generation_page) {
|
||||||
$container_id = (string) get_parameter('containerID');
|
$container_id = (string) get_parameter('containerID');
|
||||||
@ -289,7 +307,7 @@ if ($get_double_auth_generation_page) {
|
|||||||
$html .= '</p>';
|
$html .= '</p>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
$html .= '<div class="center_align">';
|
$html .= '<div class="center_align">';
|
||||||
$html .= __('Code').": <b>$secret</b>";
|
$html .= __('Code').': <b>'.$secret.'</b>';
|
||||||
$html .= '<br>';
|
$html .= '<br>';
|
||||||
$html .= __('QR').': <br>';
|
$html .= __('QR').': <br>';
|
||||||
$html .= '<div id="qr-container"></div>';
|
$html .= '<div id="qr-container"></div>';
|
||||||
@ -319,7 +337,7 @@ if ($get_double_auth_generation_page) {
|
|||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
// Load the same page with another secret
|
// Load the same page with another secret
|
||||||
$("input[name=\"continue_to_generate\"]").click(function(e) {
|
$("#button-continue_to_generate").click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var containerID = "<?php echo $container_id; ?>";
|
var containerID = "<?php echo $container_id; ?>";
|
||||||
@ -360,7 +378,7 @@ if ($get_double_auth_generation_page) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Load the validation page
|
// Load the validation page
|
||||||
$("input[name=\"continue_to_validate\"]").click(function(e) {
|
$("#button-continue_to_validate").click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!confirm("<?php echo __('Are you introduced the code in the authenticator app yet?'); ?>")) {
|
if (!confirm("<?php echo __('Are you introduced the code in the authenticator app yet?'); ?>")) {
|
||||||
@ -455,7 +473,7 @@ if ($get_double_auth_validation_page) {
|
|||||||
$(this).removeClass("red").css('border-color', '#cbcbcb');
|
$(this).removeClass("red").css('border-color', '#cbcbcb');
|
||||||
});
|
});
|
||||||
|
|
||||||
$("input[name=\"continue_to_validate\"]").click(function(e) {
|
$("#button-continue_to_validate").click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// Hide the error message
|
// Hide the error message
|
||||||
@ -463,7 +481,7 @@ if ($get_double_auth_validation_page) {
|
|||||||
|
|
||||||
var containerID = "<?php echo $container_id; ?>";
|
var containerID = "<?php echo $container_id; ?>";
|
||||||
|
|
||||||
$("input[name=\"continue_to_validate\"]").prop('enabled', false).hide();
|
$("#button-continue_to_validate").prop('enabled', false).hide();
|
||||||
$("div#button-container").find("img").show();
|
$("div#button-container").find("img").show();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -493,7 +511,7 @@ if ($get_double_auth_validation_page) {
|
|||||||
}
|
}
|
||||||
// Invalid code
|
// Invalid code
|
||||||
else if (data === false) {
|
else if (data === false) {
|
||||||
$("input[name=\"continue_to_validate\"]").prop('enabled', true).show();
|
$("#button-continue_to_validate").prop('enabled', true).show();
|
||||||
$("div#button-container").find("img").hide();
|
$("div#button-container").find("img").hide();
|
||||||
$("input#text-code").addClass("red").css('border-color', '#c00');
|
$("input#text-code").addClass("red").css('border-color', '#c00');
|
||||||
|
|
||||||
@ -501,7 +519,7 @@ if ($get_double_auth_validation_page) {
|
|||||||
}
|
}
|
||||||
// Valid code but not saved
|
// Valid code but not saved
|
||||||
else if (data === 1) {
|
else if (data === 1) {
|
||||||
$("input[name=\"continue_to_validate\"]").prop('enabled', true).show();
|
$("#button-continue_to_validate").prop('enabled', true).show();
|
||||||
$("div#button-container").find("img").hide();
|
$("div#button-container").find("img").hide();
|
||||||
$("input#text-code").addClass("red").css('border-color', '#c00');
|
$("input#text-code").addClass("red").css('border-color', '#c00');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user