From 7011eee87174895ab386e46c35a58dba94e1e4d9 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Wed, 19 Apr 2017 13:26:20 +0200 Subject: [PATCH 01/14] Added a new page to reset password, for now without code, only visual page and error control --- pandora_console/general/login_page.php | 49 ++++- pandora_console/general/reset_pass.php | 202 ++++++++++++++++++++ pandora_console/include/functions_users.php | 27 +++ pandora_console/index.php | 55 +++++- 4 files changed, 331 insertions(+), 2 deletions(-) create mode 100644 pandora_console/general/reset_pass.php diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index 858ad945c0..e185b60550 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -210,7 +210,14 @@ echo '
'; } break; } - + + $reset_pass_link = 'reset_pass.php'; + // Reset password link + echo '
'; + echo '' . __('Forgotten your password?'); + echo ''; + echo '
'; + echo '
'; echo '
'; echo ''; echo '
'.$pandora_version.(($develop_bypass == 1) ? ' '.__('Build').' '.$build_version : '') . '
'; echo '
'; +if ($mail != "") { + echo '
'; + echo '
'; + echo '
'; + echo html_print_image('images/icono_logo_pandora.png', true, array("alt" => __('Password reset'), "border" => 0)); + echo '
'; + echo '
'; + echo '
'; + echo '

' . __('INFO') . '

'; + echo '

' . __('An email has been sent to the user\'s address') . '

'; + echo '
'; + echo '
'; + html_print_submit_button("Ok", 'reset_correct_button', false); + echo '
'; + echo '
'; + echo '
'; + echo '
'; +} + if (isset ($login_failed)) { echo '
'; echo '
'; @@ -512,5 +538,26 @@ html_print_div(array('id' => 'forced_title_layer', 'class' => 'forced_title_laye + + $(document).ready (function () { + $(function() { + $("#reset_correct").dialog({ + resizable: true, + draggable: true, + modal: true, + height: 220, + width: 528, + clickOutside: true, + overlay: { + opacity: 0.5, + background: "black" + } + }); + }); + + $("#submit-reset_correct_button").click (function () { + $("#reset_correct").dialog('close'); + }); + }); /* ]]> */ diff --git a/pandora_console/general/reset_pass.php b/pandora_console/general/reset_pass.php new file mode 100644 index 0000000000..d3ef5d06df --- /dev/null +++ b/pandora_console/general/reset_pass.php @@ -0,0 +1,202 @@ +'; + echo '
'; + echo '
'; + if (defined ('PANDORA_ENTERPRISE')) { + if(isset ($config['custom_logo'])){ + echo 'pandora_console'; + } + else{ + echo 'pandora_console'; + } + } + else{ + echo 'pandora_console'; + } + echo '
'; + echo '
    '; + echo '
  • docs pandora
  • '; + echo '
  • ' . __('Docs') . '
  • '; + echo '
  • support pandora
  • '; + echo '
  • ' . __('Support') . '
  • '; + echo '
'; + echo '
'; + + echo ''; + + echo '
'; + echo '
'.$pandora_version.(($develop_bypass == 1) ? ' '.__('Build').' '.$build_version : '') . '
'; + echo '
'; + +if ($show_error) { + echo '
'; + echo '
'; + echo '
'; + echo html_print_image('images/icono_stop.png', true, array("alt" => __('Reset password failed'), "border" => 0)); + echo '
'; + echo '
'; + echo '
'; + echo '

' . __('ERROR') . '

'; + echo '

' . $error . '

'; + echo '
'; + echo '
'; + html_print_submit_button("Ok", 'reset_pass_error', false); + echo '
'; + echo '
'; + echo '
'; + echo '
'; +} + +ui_require_css_file ('dialog'); +ui_require_css_file ('jquery-ui-1.10.0.custom'); +ui_require_jquery_file('jquery-ui-1.10.0.custom'); + +?> + + \ No newline at end of file diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index e12cf6611f..6759c5aaec 100755 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -891,4 +891,31 @@ function users_get_strict_mode_groups($id_user, $return_group_all) { return $return_user_groups; } + +function check_user_id ($id_user) { + global $config; + + $exists = db_get_value ('id_user', 'tusuario', 'id_user', $id_user); + + if ($exists) { + return true; + } + else { + return false; + } +} + +function check_user_have_mail ($id_user) { + global $config; + + $exists_mail = db_get_value ('email', 'tusuario', 'id_user', $id_user); + + if ($exists_mail) { + return $exists_mail; + } + else { + return false; + } +} + ?> diff --git a/pandora_console/index.php b/pandora_console/index.php index 78997fbe56..f4d3c6d0cb 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -547,7 +547,60 @@ if (! isset ($config['id_user'])) { } // There is no user connected else { - require_once ('general/login_page.php'); + $reset = (boolean)get_parameter('reset', 0); + $first = (boolean)get_parameter('first', 0); + if (!$reset) { + require_once ('general/login_page.php'); + } + else { + $user_reset_pass = get_parameter('user_reset_pass', ""); + $error = ""; + $mail = ""; + $show_error = false; + + if (!$first) { + if ($reset) { + if ($user_reset_pass == '') { + $reset = false; + $error = __('Id user cannot be empty'); + $show_error = true; + } + else { + $check_user = check_user_id($user_reset_pass); + + if (!$check_user) { + $reset = false; + $error = __('User no exists in db'); + $show_error = true; + } + else { + $check_mail = check_user_have_mail($user_reset_pass); + + if (!$check_mail) { + $reset = false; + $error = __('User no have any email direction asociated'); + $show_error = true; + } + else { + $mail = $check_mail; + } + } + } + } + + if (!$reset) { + require_once ('general/reset_pass.php'); + } + else { + // MANDAR CORREO ELECTRÓNICO AL USUARIO Y VOLVER A LA PÁGINA DE INICIO + + require_once ('general/login_page.php'); + } + } + else { + require_once ('general/reset_pass.php'); + } + } while (@ob_end_flush ()); exit (""); } From bd30625532129432cd3a73edb08afdfdee96dc3a Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Wed, 19 Apr 2017 15:10:51 +0200 Subject: [PATCH 02/14] Added return to login button --- pandora_console/general/reset_pass.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pandora_console/general/reset_pass.php b/pandora_console/general/reset_pass.php index d3ef5d06df..a3f83753d6 100644 --- a/pandora_console/general/reset_pass.php +++ b/pandora_console/general/reset_pass.php @@ -102,8 +102,15 @@ echo '
'; html_print_submit_button(__("Reset password"), "login_button", false, 'class="sub next_login"'); echo '
'; + echo ''; + + echo '
'; + echo ''; echo '
'; - echo '