Merge branch '635-reset-or-recover-password-in-pandora-node-and-meta-dev' into 'develop'
635 reset or recover password in pandora node and meta dev See merge request !389
This commit is contained in:
commit
b21e09deef
|
@ -217,7 +217,18 @@ echo '<div class="login_page">';
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ($config['enterprise_installed']) {
|
||||
if ($config["reset_pass_option"]) {
|
||||
$reset_pass_link = 'reset_pass.php';
|
||||
// Reset password link
|
||||
echo '<div style="width:70%; height:40px; margin-right:auto; margin-left:auto; margin-top:20px; text-align:center;">';
|
||||
echo '<a style="color: white !important;" href="index.php?reset=true&first=true">' . __('Forgotten your password?');
|
||||
echo '</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</form></div>';
|
||||
echo '<div class="login_data">';
|
||||
echo '<div class ="text_banner_login">';
|
||||
|
@ -266,6 +277,63 @@ echo '</div>';
|
|||
echo '<div id="ver_num">'.$pandora_version.(($develop_bypass == 1) ? ' '.__('Build').' '.$build_version : '') . '</div>';
|
||||
echo '</div>';
|
||||
|
||||
if ($process_error_message == '' && $mail != "") {
|
||||
echo '<div id="reset_correct" title="' . __('Password reset') . '">';
|
||||
echo '<div class="content_alert">';
|
||||
echo '<div class="icon_message_alert">';
|
||||
echo html_print_image('images/icono_logo_pandora.png', true, array("alt" => __('Password reset'), "border" => 0));
|
||||
echo '</div>';
|
||||
echo '<div class="content_message_alert">';
|
||||
echo '<div class="text_message_alert">';
|
||||
echo '<h1>' . __('INFO') . '</h1>';
|
||||
echo '<p>' . __('An email has been sent to the user\'s address') . '</p>';
|
||||
echo '</div>';
|
||||
echo '<div class="button_message_alert">';
|
||||
html_print_submit_button("Ok", 'reset_correct_button', false);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
else if ($process_error_message != '') {
|
||||
echo '<div id="reset_correct" title="' . __('Password reset') . '">';
|
||||
echo '<div class="content_alert">';
|
||||
echo '<div class="icon_message_alert">';
|
||||
echo html_print_image('images/icono_stop.png', true, array("alt" => __('Password reset'), "border" => 0));
|
||||
echo '</div>';
|
||||
echo '<div class="content_message_alert">';
|
||||
echo '<div class="text_message_alert">';
|
||||
echo '<h1>' . __('ERROR') . '</h1>';
|
||||
echo '<p>' . $process_error_message . '</p>';
|
||||
echo '</div>';
|
||||
echo '<div class="button_message_alert">';
|
||||
html_print_submit_button("Ok", 'reset_correct_button', false);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
if ($correct_reset_pass_process != "") {
|
||||
echo '<div id="final_process_correct" title="' . __('Password reset') . '">';
|
||||
echo '<div class="content_alert">';
|
||||
echo '<div class="icon_message_alert">';
|
||||
echo html_print_image('images/icono_logo_pandora.png', true, array("alt" => __('Password reset'), "border" => 0));
|
||||
echo '</div>';
|
||||
echo '<div class="content_message_alert">';
|
||||
echo '<div class="text_message_alert">';
|
||||
echo '<h1>' . __('SUCCESS') . '</h1>';
|
||||
echo '<p>' . $correct_reset_pass_process . '</p>';
|
||||
echo '</div>';
|
||||
echo '<div class="button_message_alert">';
|
||||
html_print_submit_button("Ok", 'final_process_correct_button', false);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if (isset ($login_failed)) {
|
||||
echo '<div id="login_failed" title="' . __('Login failed') . '">';
|
||||
echo '<div class="content_alert">';
|
||||
|
@ -518,5 +586,47 @@ html_print_div(array('id' => 'forced_title_layer', 'class' => 'forced_title_laye
|
|||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
$(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');
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready (function () {
|
||||
$(function() {
|
||||
$("#final_process_correct").dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 220,
|
||||
width: 528,
|
||||
clickOutside: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#submit-final_process_correct_button").click (function () {
|
||||
$("#final_process_correct").dialog('close');
|
||||
});
|
||||
});
|
||||
/* ]]> */
|
||||
</script>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 483 B |
|
@ -2753,4 +2753,5 @@ function remove_right_zeros ($value) {
|
|||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -245,10 +245,25 @@ function config_update_config () {
|
|||
$error_update[] = __('Metaconsole agent cache');
|
||||
if (!config_update_value ('log_collector', (bool)get_parameter('log_collector')))
|
||||
$error_update[] = __('Activate Log Collector');
|
||||
if (!config_update_value ('reset_pass_option', (bool)get_parameter('reset_pass_option')))
|
||||
$error_update[] = __('Activate reset password');
|
||||
|
||||
$inventory_changes_blacklist = get_parameter('inventory_changes_blacklist', array());
|
||||
if (!config_update_value ('inventory_changes_blacklist', implode(',',$inventory_changes_blacklist)))
|
||||
$error_update[] = __('Inventory changes blacklist');
|
||||
|
||||
if (!config_update_value ('email_from_dir', get_parameter('email_from_dir')))
|
||||
$error_update[] = __('From dir');
|
||||
if (!config_update_value ('email_from_name', get_parameter('email_from_name')))
|
||||
$error_update[] = __('From name');
|
||||
if (!config_update_value ('email_smtpServer', get_parameter('email_smtpServer')))
|
||||
$error_update[] = __('Server SMTP');
|
||||
if (!config_update_value ('email_smtpPort', (int)get_parameter('email_smtpPort')))
|
||||
$error_update[] = __('Port SMTP');
|
||||
if (!config_update_value ('email_username', get_parameter('email_username')))
|
||||
$error_update[] = __('Email user');
|
||||
if (!config_update_value ('email_password', get_parameter('email_password')))
|
||||
$error_update[] = __('Email password');
|
||||
|
||||
}
|
||||
break;
|
||||
|
@ -991,6 +1006,10 @@ function config_process_config () {
|
|||
config_update_value ('log_collector', 0);
|
||||
}
|
||||
|
||||
if (!isset ($config["reset_pass_option"])) {
|
||||
config_update_value ('reset_pass_option', 0);
|
||||
}
|
||||
|
||||
if (!isset ($config["include_agents"])) {
|
||||
config_update_value ('include_agents', 0);
|
||||
}
|
||||
|
@ -1190,7 +1209,31 @@ function config_process_config () {
|
|||
if (!isset ($config['history_db_delay'])) {
|
||||
config_update_value ( 'history_db_delay', 0);
|
||||
}
|
||||
|
||||
|
||||
if (!isset ($config['email_from_dir'])) {
|
||||
config_update_value ( 'email_from_dir', "pandora@pandorafms.org");
|
||||
}
|
||||
|
||||
if (!isset ($config['email_from_name'])) {
|
||||
config_update_value ( 'email_from_name', "Pandora FMS");
|
||||
}
|
||||
|
||||
if (!isset ($config['email_smtpServer'])) {
|
||||
config_update_value ( 'email_smtpServer', "127.0.0.1");
|
||||
}
|
||||
|
||||
if (!isset ($config['email_smtpPort'])) {
|
||||
config_update_value ( 'email_smtpPort', 25);
|
||||
}
|
||||
|
||||
if (!isset ($config['email_username'])) {
|
||||
config_update_value ( 'email_username', "");
|
||||
}
|
||||
|
||||
if (!isset ($config['email_password'])) {
|
||||
config_update_value ( 'email_password', "");
|
||||
}
|
||||
|
||||
if (!isset ($config['activate_gis'])) {
|
||||
config_update_value ( 'activate_gis', 0);
|
||||
}
|
||||
|
|
|
@ -2040,6 +2040,9 @@ function html_print_label ($text, $id, $return = false, $options = false) {
|
|||
if ($options) {
|
||||
if (isset ($options['class']))
|
||||
$output .= 'class="'.$options['class'].'" ';
|
||||
|
||||
if (isset ($options['style']))
|
||||
$output .= 'style="'.$options['style'].'" ';
|
||||
}
|
||||
|
||||
$output .= 'for="'.$id.'" >';
|
||||
|
|
|
@ -891,4 +891,5 @@ function users_get_strict_mode_groups($id_user, $return_group_all) {
|
|||
|
||||
return $return_user_groups;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -36,9 +36,7 @@ function clippy_extension_cron_send_email() {
|
|||
'intro' => '<table>' .
|
||||
'<tr>' .
|
||||
'<td class="context_help_body">' .
|
||||
'<div style="word-break: break-word;">' .
|
||||
__('The configuration of email for the task email is in the file:') . '<br />' .
|
||||
'<www>/pandora_console/enterprise/extensions/cron/email_config.php <br />' .
|
||||
__('The configuration of email for the task email is in the enterprise setup:') . '<br />' .
|
||||
__('Please check if the email configuration is correct.') .
|
||||
'</div>' .
|
||||
'</td>' .
|
||||
|
|
|
@ -544,7 +544,141 @@ if (! isset ($config['id_user'])) {
|
|||
}
|
||||
// There is no user connected
|
||||
else {
|
||||
require_once ('general/login_page.php');
|
||||
if ($config['enterprise_installed']) {
|
||||
enterprise_include_once ('include/functions_reset_pass.php');
|
||||
}
|
||||
|
||||
$correct_pass_change = (boolean)get_parameter('correct_pass_change', 0);
|
||||
$reset = (boolean)get_parameter('reset', 0);
|
||||
$first = (boolean)get_parameter('first', 0);
|
||||
$reset_hash = get_parameter('reset_hash', "");
|
||||
|
||||
if ($correct_pass_change) {
|
||||
$correct_reset_pass_process = "";
|
||||
$process_error_message = "";
|
||||
$pass1 = get_parameter('pass1');
|
||||
$pass2 = get_parameter('pass2');
|
||||
$id_user = get_parameter('id_user');
|
||||
|
||||
if ($pass1 == $pass2) {
|
||||
$res = update_user_password ($id_user, $pass1);
|
||||
if ($res) {
|
||||
$correct_reset_pass_process = __('Password changed successfully');
|
||||
}
|
||||
else {
|
||||
$process_error_message = __('Failed to change password');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$process_error_message = __('Passwords must be the same');
|
||||
}
|
||||
require_once ('general/login_page.php');
|
||||
}
|
||||
else {
|
||||
if ($reset_hash != "") {
|
||||
$hash_data = explode(":::", $reset_hash);
|
||||
$id_user = $hash_data[0];
|
||||
$codified_hash = $hash_data[1];
|
||||
|
||||
$db_reset_pass_entry = db_get_value_filter('reset_time', 'treset_pass', array('id_user' => $id_user, 'cod_hash' => $id_user . ":::" . $codified_hash));
|
||||
$process_error_message = "";
|
||||
|
||||
if ($db_reset_pass_entry) {
|
||||
if (($db_reset_pass_entry + SECONDS_2HOUR) < time()) {
|
||||
$process_error_message = __('Too much time since password change request');
|
||||
delete_reset_pass_entry($id_user);
|
||||
require_once ('general/login_page.php');
|
||||
}
|
||||
else {
|
||||
delete_reset_pass_entry($id_user);
|
||||
require_once ('enterprise/include/process_reset_pass.php');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$process_error_message = __('This user has not requested a password change');
|
||||
require_once ('general/login_page.php');
|
||||
}
|
||||
}
|
||||
else {
|
||||
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) {
|
||||
if ($config['enterprise_installed']) {
|
||||
require_once ('enterprise/include/reset_pass.php');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$cod_hash = $user_reset_pass . "::::" . md5(rand(10, 1000000) . rand(10, 1000000) . rand(10, 1000000));
|
||||
|
||||
$subject = '[Pandora] '.__('Reset password');
|
||||
$body = __('This is the automatic message to the user');
|
||||
$body .= ' "<strong>' . $user_reset_pass . '"</strong>';
|
||||
$body .= '<p />';
|
||||
$body .= __('Please, click in the link below to reset your password');
|
||||
$body .= '<p />';
|
||||
$body .= '<a href="' . $config['homeurl'] . 'index.php?reset_hash=' . $cod_hash . '">' . __('Reset your password') . '</a>';
|
||||
$body .= '<p />';
|
||||
$body .= 'Pandora FMS';
|
||||
$body .= '<p />';
|
||||
$body .= '<em>'.__('Please do not answer or reply to this email').'</em>';
|
||||
|
||||
$result = send_email_to_user($mail, $body, $subject);
|
||||
|
||||
$process_error_message = "";
|
||||
if (!$result) {
|
||||
$process_error_message = __('Error at sending the email');
|
||||
}
|
||||
else {
|
||||
send_token_to_db($user_reset_pass, $cod_hash);
|
||||
}
|
||||
|
||||
require_once ('general/login_page.php');
|
||||
}
|
||||
}
|
||||
else {
|
||||
require_once ('enterprise/include/reset_pass.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (@ob_end_flush ());
|
||||
exit ("</html>");
|
||||
}
|
||||
|
|
|
@ -2927,3 +2927,11 @@ create table IF NOT EXISTS `tphase`(
|
|||
`timeout` int unsigned default null,
|
||||
PRIMARY KEY (`phase_id`,`transaction_id`)
|
||||
) engine=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `treset_pass` (
|
||||
`id` bigint(10) unsigned NOT NULL auto_increment,
|
||||
`id_user` varchar(100) NOT NULL default '',
|
||||
`cod_hash` varchar(100) NOT NULL default '',
|
||||
`reset_time` int(10) unsigned NOT NULL default 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
Loading…
Reference in New Issue