/**
  * Generate forgotpassword object
  *
  * @param int $userID
  * @param string $passwordHash
  * @param int $time
  *
  * @return array An array with operation status, always true if userID is ok
  */
 public static function forgotpassword($userID, $passwordHash, $time)
 {
     $user = eZUser::fetch($userID);
     if ($user instanceof eZUser) {
         $forgotPasswdObj = eZForgotPassword::createNew($userID, $passwordHash, $time);
         $forgotPasswdObj->store();
         return array('status' => true);
     } else {
         eZDebug::writeError("Failed to generate password hash for user {$userID} (could not fetch user)", __METHOD__);
         return array('status' => false);
     }
 }
Пример #2
0
 $password = eZUser::createPassword($passwordLength);
 $passwordConfirm = $password;
 if ($module->hasActionParameter("Email") && eZMail::validate($module->actionParameter("Email"))) {
     $email = $module->actionParameter("Email");
     if (trim($email) != "") {
         $users = eZPersistentObject::fetchObjectList(eZUser::definition(), null, array('email' => $email), null, null, true);
     }
     if (!empty($users)) {
         $user = $users[0];
         $time = time();
         $hashKey = md5($time . ":" . mt_rand());
         $db = eZDB::instance();
         $db->begin();
         // Remove previous generated hash keys for same user
         eZForgotPassword::removeByUserID($user->id());
         $forgotPasswdObj = eZForgotPassword::createNew($user->id(), $hashKey, $time);
         $forgotPasswdObj->store();
         $userToSendEmail = $user;
         require_once "kernel/common/template.php";
         $receiver = $email;
         $mail = new eZMail();
         if (!$mail->validate($receiver)) {
         }
         $tpl = templateInit();
         $tpl->setVariable('user', $userToSendEmail);
         $tpl->setVariable('object', $userToSendEmail->attribute('contentobject'));
         $tpl->setVariable('password', $password);
         $tpl->setVariable('link', true);
         $tpl->setVariable('hash_key', $hashKey);
         $tpl->setVariable('hash_key_lifetime', date("d/m/Y H:i", time() + $forgotPasswdHashLifeTime));
         $http = eZHTTPTool::instance();