execute( $par ); } /** * Let users recover their password. * @addtogroup SpecialPage */ class PasswordResetForm extends SpecialPage { function __construct( $name=null, $reset=null ) { if( $name !== null ) { $this->mName = $name; $this->mTemporaryPassword = $reset; } else { global $wgRequest; $this->mName = $wgRequest->getVal( 'wpName' ); $this->mTemporaryPassword = $wgRequest->getVal( 'wpPassword' ); } } /** * Main execution point */ function execute( $par='' ) { global $wgUser, $wgAuth, $wgOut, $wgRequest; if( !$wgAuth->allowPasswordChange() ) { $this->error( wfMsg( 'resetpass_forbidden' ) ); return; } if( $this->mName === null && !$wgRequest->wasPosted() ) { $this->error( wfMsg( 'resetpass_missing' ) ); return; } if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { $newpass = $wgRequest->getVal( 'wpNewPassword' ); $retype = $wgRequest->getVal( 'wpRetype' ); try { $this->attemptReset( $newpass, $retype ); $wgOut->addWikiText( wfMsg( 'resetpass_success' ) ); $data = array( 'action' => 'submitlogin', 'wpName' => $this->mName, 'wpPassword' => $newpass, 'returnto' => $wgRequest->getVal( 'returnto' ), ); if( $wgRequest->getCheck( 'wpRemember' ) ) { $data['wpRemember'] = 1; } $login = new LoginForm( new FauxRequest( $data, true ) ); $login->execute(); return; } catch( PasswordError $e ) { $this->error( $e->getMessage() ); } } $this->showForm(); } function error( $msg ) { global $wgOut; $wgOut->addHtml( '
' . ' | ' . Xml::checkLabel( wfMsg( 'remembermypassword' ), 'wpRemember', 'wpRemember', $wgRequest->getCheck( 'wpRemember' ) ) . ' | ' . '
' . ' | ' . wfSubmitButton( wfMsgHtml( 'resetpass_submit' ) ) . ' | ' . '