diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index a629abc0ad..f37c3244ae 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1357,7 +1357,8 @@ INSERT INTO `tcontainer` SET `name` = 'Default graph container'; CREATE TABLE IF NOT EXISTS `treset_pass_history` ( `id` int(10) unsigned NOT NULL auto_increment, `id_user` varchar(60) NOT NULL, - `reset_moment` date default NULL, + `reset_moment` datetime NOT NULL, + `success` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index b4e25c9eac..b8ece40c98 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -2754,4 +2754,14 @@ function remove_right_zeros ($value) { } } +function register_pass_change_try ($id_user, $success) { + $values = array(); + $values['id_user'] = $id_user; + $reset_pass_moment = new DateTime('now'); + $reset_pass_moment = $reset_pass_moment->format("Y-m-d H:i:s"); + $values['reset_moment'] = $reset_pass_moment; + $values['success'] = $success; + db_process_sql_insert('treset_pass_history', $values); +} + ?> diff --git a/pandora_console/index.php b/pandora_console/index.php index 5a32eaa670..683490f646 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -585,18 +585,17 @@ if (! isset ($config['id_user'])) { if ($res) { $correct_reset_pass_process = __('Password changed successfully'); - $values = array(); - $values['id_user'] = $id_user; - $reset_pass_moment = new DateTime('now'); - $reset_pass_moment = $reset_pass_moment->format("Y-m-d H:i:s"); - $values['reset_moment'] = $reset_pass_moment; - db_process_sql_insert('treset_pass_history', $values); + register_pass_change_try($id_user, 1); } else { + register_pass_change_try($id_user, 0); + $process_error_message = __('Failed to change password'); } } else { + register_pass_change_try($id_user, 0); + $process_error_message = __('Passwords must be the same'); } require_once ('general/login_page.php'); @@ -612,6 +611,7 @@ if (! isset ($config['id_user'])) { if ($db_reset_pass_entry) { if (($db_reset_pass_entry + SECONDS_2HOUR) < time()) { + register_pass_change_try($id_user, 0); $process_error_message = __('Too much time since password change request'); delete_reset_pass_entry($id_user); require_once ('general/login_page.php'); @@ -622,6 +622,7 @@ if (! isset ($config['id_user'])) { } } else { + register_pass_change_try($id_user, 0); $process_error_message = __('This user has not requested a password change'); require_once ('general/login_page.php'); } @@ -648,6 +649,7 @@ if (! isset ($config['id_user'])) { if (!$check_user) { $reset = false; + register_pass_change_try($user_reset_pass, 0); $error = __('Error in reset password request'); $show_error = true; } @@ -656,6 +658,7 @@ if (! isset ($config['id_user'])) { if (!$check_mail) { $reset = false; + register_pass_change_try($user_reset_pass, 0); $error = __('This user doesn\'t have a valid email address'); $show_error = true; } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 0cb01cf9b5..75b93af530 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1149,7 +1149,8 @@ CREATE TABLE IF NOT EXISTS `tuser_double_auth` ( CREATE TABLE IF NOT EXISTS `treset_pass_history` ( `id` int(10) unsigned NOT NULL auto_increment, `id_user` varchar(60) NOT NULL, - `reset_moment` datetime not null default 0, + `reset_moment` datetime NOT NULL, + `success` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;