Example #1
0
 /**
  * Send password recovery for a user.
  *
  * @param $email email of the user
  *
  * @return nothing : send email or display error message
  **/
 function forgetPassword($email)
 {
     global $CFG_GLPI;
     echo "<div class='center'>";
     if ($this->getFromDBbyEmail($email, "`glpi_users`.`is_active` AND NOT `glpi_users`.`is_deleted`")) {
         // Send token if auth DB or not external auth defined
         if ($this->fields["authtype"] == Auth::DB_GLPI || !Auth::useAuthExt()) {
             if (NotificationMail::isUserAddressValid($email)) {
                 $input['password_forget_token'] = sha1(Toolbox::getRandomString(30));
                 $input['password_forget_token_date'] = $_SESSION["glpi_currenttime"];
                 $input['id'] = $this->fields['id'];
                 $this->update($input);
                 // Notication on root entity (glpi_users.entities_id is only a pref)
                 NotificationEvent::raiseEvent('passwordforget', $this, array('entities_id' => 0));
                 _e('An email has been sent to your email address. The email contains information for reset your password.');
             } else {
                 _e('Invalid email address');
             }
         } 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'] . "/index.php\">" . __s('Back') . "</a>";
     echo "</div>";
 }
Example #2
0
 /**
  * Send password recovery for a user.
  *
  * @param $email email of the user
  *
  * @return nothing : send email or display error message
  **/
 function forgetPassword($email)
 {
     global $LANG, $CFG_GLPI;
     echo "<div class='center'>";
     if ($this->getFromDBbyEmail($email)) {
         // Send token if auth DB or not external auth defined
         if ($this->fields["authtype"] == Auth::DB_GLPI || !Auth::useAuthExt()) {
             if (NotificationMail::isUserAddressValid($email)) {
                 $input['token'] = sha1(getRandomString(30));
                 $input['tokendate'] = $_SESSION["glpi_currenttime"];
                 $input['id'] = $this->fields['id'];
                 $this->update($input);
                 NotificationEvent::raiseEvent('passwordforget', $this);
                 echo $LANG['users'][10];
             } else {
                 echo $LANG['mailing'][110];
             }
         } else {
             echo $LANG['users'][9];
         }
     } else {
         echo $LANG['users'][8];
     }
     echo "<br>";
     echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/index.php\">" . $LANG['buttons'][13] . "</a>";
     echo "</div>";
 }