/** * Sends a new password to the given user. * * @param \wcf\data\user\UserEditor $userEditor */ protected function sendNewPassword(UserEditor $userEditor) { $newPassword = PasswordUtil::getRandomPassword(REGISTER_PASSWORD_MIN_LENGTH > 12 ? REGISTER_PASSWORD_MIN_LENGTH : 12); $userAction = new UserAction(array($userEditor), 'update', array('data' => array('password' => $newPassword))); $userAction->executeAction(); // send mail $mail = new Mail(array($userEditor->username => $userEditor->email), $userEditor->getLanguage()->getDynamicVariable('wcf.acp.user.sendNewPassword.mail.subject'), $userEditor->getLanguage()->getDynamicVariable('wcf.acp.user.sendNewPassword.mail', array('password' => $newPassword, 'username' => $userEditor->username))); $mail->send(); }
/** * @see \wcf\page\IPage::assignVariables() */ public function assignVariables() { parent::assignVariables(); WCF::getTPL()->assign(array('confirmMasterPassword' => $this->confirmMasterPassword, 'exampleMasterPassword' => PasswordUtil::getRandomPassword(16), 'relativeWcfDir' => RELATIVE_WCF_DIR)); }
/** * @see wcf\page\IPage::assignVariables() */ public function assignVariables() { parent::assignVariables(); WCF::getTPL()->assign(array( 'confirmMasterPassword' => $this->confirmMasterPassword, 'exampleMasterPassword' => PasswordUtil::getRandomPassword(12) )); }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); // generate new password $this->newPassword = PasswordUtil::getRandomPassword(REGISTER_PASSWORD_MIN_LENGTH > 12 ? REGISTER_PASSWORD_MIN_LENGTH : 12); // update user $this->objectAction = new UserAction(array($this->user), 'update', array('data' => array_merge($this->additionalFields, array('password' => $this->newPassword, 'lastLostPasswordRequestTime' => 0, 'lostPasswordKey' => '')))); $this->objectAction->executeAction(); // send mail $mail = new Mail(array($this->user->username => $this->user->email), WCF::getLanguage()->getDynamicVariable('wcf.user.newPassword.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.newPassword.mail', array('username' => $this->user->username, 'userID' => $this->user->userID, 'newPassword' => $this->newPassword))); $mail->send(); $this->saved(); // forward to index page HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->get('wcf.user.newPassword.success')); exit; }