コード例 #1
0
 /**
  * @return bool|string true or string on success, false on failure
  */
 protected function attemptChange(User $user, $pass, $newaddr)
 {
     if ($newaddr != '' && !Sanitizer::validateEmail($newaddr)) {
         $this->error('invalidemailaddress');
         return false;
     }
     $throttleCount = LoginForm::incLoginThrottle($user->getName());
     if ($throttleCount === true) {
         $this->error('login-throttled');
         return false;
     }
     if (!$user->checkTemporaryPassword($pass) && !$user->checkPassword($pass)) {
         $this->error('wrongpassword');
         return false;
     }
     if ($throttleCount) {
         LoginForm::clearLoginThrottle($user->getName());
     }
     list($status, $info) = Preferences::trySetUserEmail($user, $newaddr);
     if ($status !== true) {
         if ($status instanceof Status) {
             $this->getOutput()->addHTML('<p class="error">' . $this->getOutput()->parseInline($status->getWikiText($info)) . '</p>');
         }
         return false;
     }
     $user->saveSettings();
     return $info ? $info : true;
 }
コード例 #2
0
 public static function onPreferencesTrySetUserEmail($user, $newEmail, &$result)
 {
     list($status, $info) = Preferences::trySetUserEmail($user, $newEmail);
     /* @var $status Status */
     if ($status instanceof Status && !$status->isGood()) {
         $result = $status->getWikiText($info);
         return false;
     }
     return true;
 }