return true;
}
- try {
- $this->mUserName = $request->getVal( 'wpName', $this->getUser()->getName() );
- $this->mDomain = $wgAuth->getDomain();
+ $this->mUserName = $request->getVal( 'wpName', $this->getUser()->getName() );
+ $this->mDomain = $wgAuth->getDomain();
- if ( !$wgAuth->allowPasswordChange() ) {
- throw new ErrorPageError( 'changepassword', 'resetpass_forbidden' );
- }
+ if ( !$wgAuth->allowPasswordChange() ) {
+ throw new ErrorPageError( 'changepassword', 'resetpass_forbidden' );
+ }
- $this->attemptReset( $data['Password'], $data['NewPassword'], $data['Retype'] );
+ $status = $this->attemptReset( $data['Password'], $data['NewPassword'], $data['Retype'] );
- return true;
- } catch ( PasswordError $e ) {
- return $e->getMessage();
- }
+ return $status;
}
public function onSuccess() {
}
/**
- * @param string $oldpass
- * @param string $newpass
- * @param string $retype
- * @throws PasswordError When cannot set the new password because requirements not met.
+ * Checks the new password if it meets the requirements for passwords and set
+ * it as a current password, otherwise set the passed Status object to fatal
+ * and doesn't change anything
+ *
+ * @param string $oldpass The current (temporary) password.
+ * @param string $newpass The password to set.
+ * @param string $retype The string of the retype password field to check with newpass
+ * @return Status
*/
protected function attemptReset( $oldpass, $newpass, $retype ) {
$isSelf = ( $this->mUserName === $this->getUser()->getName() );
}
if ( !$user || $user->isAnon() ) {
- throw new PasswordError( $this->msg( 'nosuchusershort', $this->mUserName )->text() );
+ return Status::newFatal( $this->msg( 'nosuchusershort', $this->mUserName ) );
}
if ( $newpass !== $retype ) {
Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'badretype' ) );
- throw new PasswordError( $this->msg( 'badretype' )->text() );
+ return Status::newFatal( $this->msg( 'badretype' ) );
}
$throttleCount = LoginForm::incLoginThrottle( $this->mUserName );
if ( $throttleCount === true ) {
$lang = $this->getLanguage();
$throttleInfo = $this->getConfig()->get( 'PasswordAttemptThrottle' );
- throw new PasswordError( $this->msg( 'changepassword-throttled' )
+ return Status::newFatal( $this->msg( 'changepassword-throttled' )
->params( $lang->formatDuration( $throttleInfo['seconds'] ) )
- ->text()
);
}
// @todo Make these separate messages, since the message is written for both cases
if ( !$user->checkTemporaryPassword( $oldpass ) && !$user->checkPassword( $oldpass ) ) {
Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'wrongpassword' ) );
- throw new PasswordError( $this->msg( 'resetpass-wrong-oldpass' )->text() );
+ return Status::newFatal( $this->msg( 'resetpass-wrong-oldpass' ) );
}
// User is resetting their password to their old password
if ( $oldpass === $newpass ) {
- throw new PasswordError( $this->msg( 'resetpass-recycled' )->text() );
+ return Status::newFatal( $this->msg( 'resetpass-recycled' ) );
}
// Do AbortChangePassword after checking mOldpass, so we don't leak information
$abortMsg = 'resetpass-abort-generic';
if ( !Hooks::run( 'AbortChangePassword', array( $user, $oldpass, $newpass, &$abortMsg ) ) ) {
Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'abortreset' ) );
- throw new PasswordError( $this->msg( $abortMsg )->text() );
+ return Status::newFatal( $this->msg( $abortMsg ) );
}
// Please reset throttle for successful logins, thanks!
Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'success' ) );
} catch ( PasswordError $e ) {
Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'error' ) );
- throw new PasswordError( $e->getMessage() );
+ return Status::newFatal( new RawMessage( $e->getMessage() ) );
}
if ( $isSelf ) {
}
$user->saveSettings();
$this->resetPasswordExpiration( $user );
+ return Status::newGood();
}
public function requiresUnblock() {
__METHOD__
);
}
+
+ protected function getDisplayFormat() {
+ return 'ooui';
+ }
}