/** * @param $input **/ function updateForgottenPassword($input) { global $CFG_GLPI; echo "<div class='center'>"; if ($this->getFromDBbyEmail($input['email'], "`glpi_users`.`is_active` AND NOT `glpi_users`.`is_deleted`")) { if ($this->fields["authtype"] == Auth::DB_GLPI || !Auth::useAuthExt()) { if ($input['password_forget_token'] == $this->fields['password_forget_token'] && abs(strtotime($_SESSION["glpi_currenttime"]) - strtotime($this->fields['password_forget_token_date'])) < DAY_TIMESTAMP) { $input['id'] = $this->fields['id']; if (Config::validatePassword($input["password"]) && $this->update($input)) { _e('Reset password successful.'); // $input2['password_forget_token'] = ''; $input2['password_forget_token_date'] = NULL; $input2['id'] = $this->fields['id']; $this->update($input2); } else { // Force display on error Html::displayMessageAfterRedirect(); } } else { _e('Your password reset request has expired or is invalid. Please renew it.'); } } else { _e("The authentication method configuration doesn't allow you to change your password."); } } else { _e('Email address not found.'); } echo "<br>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "'>" . __('Back') . "</a>"; echo "</div>"; }
printf("Authent: %s\n", Auth::getMethodName($user->getField('authtype'), $user->getField('auths_id'))); printf("Active: %s\n\n", $user->getField('is_active') ? 'yes' : 'no'); } $user = new User(); if ($user->getFromDBbyName($_GET['user'])) { displayUser($user); $in = []; if ($_GET['enable']) { $in['is_active'] = 1; } else { if ($_GET['disable']) { $in['is_active'] = 0; } } if ($_GET['password']) { if (Config::validatePassword($input["password"])) { $_SESSION['glpiID'] = $user->getID(); // to allow change $in['password'] = $in['password2'] = $_GET['password']; } else { die("Invalid new password\n"); } } if ($_GET['db']) { $in['authtype'] = 1; $in['auths_id'] = Auth::DB_GLPI; } if (count($in)) { $in['id'] = $user->getID(); if ($user->update($in)) { unset($in['id'], $in['password2']);