<?php
+/**
+ * @file
+ * @ingroup SpecialPage
+ */
/** Constructor */
function wfSpecialResetpass( $par ) {
/**
* Let users recover their password.
- * @addtogroup SpecialPage
+ * @ingroup SpecialPage
*/
class PasswordResetForm extends SpecialPage {
function __construct( $name=null, $reset=null ) {
$this->mTemporaryPassword = $wgRequest->getVal( 'wpPassword' );
}
}
-
+
/**
* Main execution point
*/
- function execute( $par='' ) {
+ 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;
$retype = $wgRequest->getVal( 'wpRetype' );
try {
$this->attemptReset( $newpass, $retype );
- $wgOut->addWikiText( wfMsg( 'resetpass_success' ) );
-
+ $wgOut->addWikiMsg( 'resetpass_success' );
+
$data = array(
'action' => 'submitlogin',
'wpName' => $this->mName,
}
$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( '<div class="errorbox">' .
htmlspecialchars( $msg ) .
'</div>' );
}
-
+
function showForm() {
global $wgOut, $wgUser, $wgRequest;
$wgOut->disallowUserJs();
-
- $self = SpecialPage::getTitleFor( 'Resetpass' );
+
+ $self = SpecialPage::getTitleFor( 'Resetpass' );
$form =
'<div id="userloginForm">' .
wfOpenElement( 'form',
'</div>';
$wgOut->addHtml( $form );
}
-
+
function pretty( $fields ) {
$out = '';
foreach( $fields as $list ) {
}
return $out;
}
-
+
/**
* @throws PasswordError when cannot set the new password because requirements not met.
*/
if( $user->isAnon() ) {
throw new PasswordError( 'no such user' );
}
-
+
if( !$user->checkTemporaryPassword( $this->mTemporaryPassword ) ) {
throw new PasswordError( wfMsg( 'resetpass_bad_temporary' ) );
}
-
+
if( $newpass !== $retype ) {
throw new PasswordError( wfMsg( 'badretype' ) );
}
-
+
$user->setPassword( $newpass );
$user->saveSettings();
}
}
-
-?>