/**
  * Resets the specified user's parental control password and emails the password to the parent if requested.
  *
  * @param integer $userId
  * @param boolean $sendEmail
  *
  * @return string New password
  */
 public function resetParentPassword($userId, $sendEmail = true)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
     $dw->setExistingData($userId);
     $password = XenForo_Application::generateRandomString(8);
     $auth = XenForo_Authentication_Abstract::createDefault();
     $dw->set('parent_scheme_class', $auth->getClassName());
     $dw->set('parent_data', $auth->generate($password));
     $dw->save();
     $user = $dw->getMergedData();
     if ($sendEmail) {
         $params = array('user' => $user, 'password' => $password, 'boardTitle' => XenForo_Application::get('options')->boardTitle, 'boardUrl' => XenForo_Application::get('options')->boardUrl);
         $mail = XenForo_Mail::create('th_lost_password_reset_parentalcontrol', $params, $user['language_id']);
         $mail->send($user['parent_email'], (string) new XenForo_Phrase('th_parent_of_x_parentalcontrol', array('username' => $user['username'])));
     }
     return $password;
 }
示例#2
0
 /**
  * Sets the user's password.
  *
  * @param string $password
  * @param string|false $passwordConfirm If a string, ensures that the password and the confirm are the same
  * @param XenForo_Authentication_Abstract|null $auth Auth object to generate the password (or null to use default)
  * @param boolean If true, do not accept an empty password
  *
  * @return boolean
  */
 public function setPassword($password, $passwordConfirm = false, XenForo_Authentication_Abstract $auth = null, $requirePassword = false)
 {
     if ($requirePassword && $password === '') {
         return new XenForo_Phrase('please_enter_valid_password');
     }
     if ($passwordConfirm !== false && $password !== $passwordConfirm) {
         return new XenForo_Phrase('passwords_did_not_match');
     }
     if (!$auth) {
         $auth = XenForo_Authentication_Abstract::createDefault();
     }
     $authData = $auth->generate($password);
     if (!$authData) {
         return new XenForo_Phrase('please_enter_valid_password');
     }
     return array('scheme_class' => $auth->getClassName(), 'data' => $authData);
 }
示例#3
0
 /**
  * Sets the user's password.
  *
  * @param string $password
  * @param string|false $passwordConfirm If a string, ensures that the password and the confirm are the same
  * @param XenForo_Authentication_Abstract|null $auth Auth object to generate the password (or null to use default)
  * @param boolean If true, do not accept an empty password
  *
  * @return boolean
  */
 public function setPassword($password, $passwordConfirm = false, XenForo_Authentication_Abstract $auth = null, $requirePassword = false)
 {
     if ($requirePassword && $password === '') {
         $this->error(new XenForo_Phrase('please_enter_valid_password'), 'password');
         return false;
     }
     if ($passwordConfirm !== false && $password !== $passwordConfirm) {
         $this->error(new XenForo_Phrase('passwords_did_not_match'), 'password');
         return false;
     }
     if (!$auth) {
         $auth = XenForo_Authentication_Abstract::createDefault();
     }
     $authData = $auth->generate($password);
     if (!$authData) {
         $this->error(new XenForo_Phrase('please_enter_valid_password'), 'password');
         return false;
     }
     $this->set('scheme_class', $auth->getClassName());
     $this->set('data', $authData, 'xf_user_authenticate');
     return true;
 }
 /**
  * Resets the specified user's password and emails the password to them if requested.
  *
  * @param integer $userId
  * @param boolean $sendEmail
  *
  * @return string New password
  */
 public function resetPassword($userId, $sendEmail = true)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
     $dw->setExistingData($userId);
     $password = XenForo_Application::generateRandomString(8);
     $password = strtr($password, array('I' => 'i', 'l' => 'L', '0' => 'O', 'o' => 'O'));
     $password = trim($password, '_-');
     $auth = XenForo_Authentication_Abstract::createDefault();
     $dw->set('scheme_class', $auth->getClassName());
     $dw->set('data', $auth->generate($password));
     $dw->save();
     $user = $dw->getMergedData();
     if ($sendEmail) {
         $params = array('user' => $user, 'password' => $password, 'boardTitle' => XenForo_Application::get('options')->boardTitle, 'boardUrl' => XenForo_Application::get('options')->boardUrl);
         $mail = XenForo_Mail::create('user_lost_password_reset', $params, $user['language_id']);
         $mail->send($user['email'], $user['username']);
     }
     return $password;
 }
示例#5
0
 /**
  * Sets the parent's password.
  *
  * @param string $password
  * @param string|false $passwordConfirm If a string, ensures that the
  * password and the confirm are the same
  *
  * @return boolean
  */
 public function setParentPassword($password, $passwordConfirm = false)
 {
     if ($passwordConfirm !== false && $password !== $passwordConfirm) {
         $this->error(new XenForo_Phrase('passwords_did_not_match'), 'password');
         return false;
     }
     $auth = XenForo_Authentication_Abstract::createDefault();
     $authData = $auth->generate($password);
     if (!$authData) {
         $this->error(new XenForo_Phrase('please_enter_valid_password'), 'password');
         return false;
     }
     $this->set('parent_scheme_class', $auth->getClassName());
     $this->set('parent_data', $authData);
     return true;
 }