/** * @param User $user * @param string $pass * @param string $newaddr * @return Status */ private function attemptChange(User $user, $pass, $newaddr) { global $wgAuth; if ($newaddr != '' && !Sanitizer::validateEmail($newaddr)) { return Status::newFatal('invalidemailaddress'); } $throttleCount = LoginForm::incLoginThrottle($user->getName()); if ($throttleCount === true) { $lang = $this->getLanguage(); $throttleInfo = $this->getConfig()->get('PasswordAttemptThrottle'); return Status::newFatal('changeemail-throttled', $lang->formatDuration($throttleInfo['seconds'])); } if ($this->getConfig()->get('RequirePasswordforEmailChange') && !$user->checkTemporaryPassword($pass) && !$user->checkPassword($pass)) { return Status::newFatal('wrongpassword'); } if ($throttleCount) { LoginForm::clearLoginThrottle($user->getName()); } $oldaddr = $user->getEmail(); $status = $user->setEmailWithConfirmation($newaddr); if (!$status->isGood()) { return $status; } Hooks::run('PrefsEmailAudit', array($user, $oldaddr, $newaddr)); $user->saveSettings(); $wgAuth->updateExternalDB($user); return $status; }
/** * @param $user User * @param $pass string * @param $newaddr string * @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; } global $wgRequirePasswordforEmailChange; if ($wgRequirePasswordforEmailChange && !$user->checkTemporaryPassword($pass) && !$user->checkPassword($pass)) { $this->error('wrongpassword'); return false; } if ($throttleCount) { LoginForm::clearLoginThrottle($user->getName()); } $oldaddr = $user->getEmail(); $status = $user->setEmailWithConfirmation($newaddr); if (!$status->isGood()) { $this->getOutput()->addHTML('<p class="error">' . $this->getOutput()->parseInline($status->getWikiText('mailerror')) . '</p>'); return false; } wfRunHooks('PrefsEmailAudit', array($user, $oldaddr, $newaddr)); $user->saveSettings(); return $status->value; }
/** * @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; }