r48524 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48523‎ | r48524 | r48525 >
Date:19:55, 18 March 2009
Author:demon
Status:reverted (Comments)
Tags:
Comment:
Follow up to r47976 (bug 17722). For real this time: fix the regression where users can't reset passwords. Release notes were in previous commit.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialResetpass.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -589,6 +589,7 @@
590590 global $wgOut;
591591 $wgOut->addHTML( Xml::element('p', array( 'class' => 'error' ), $error ) );
592592 $reset = new SpecialResetpass();
 593+ $reset->setUser( User::newFromName( $this->mName ) );
593594 $reset->execute( $this->mName );
594595 }
595596
Index: trunk/phase3/includes/specials/SpecialResetpass.php
@@ -11,10 +11,20 @@
1212 class SpecialResetpass extends SpecialPage {
1313
1414 private $mSelfChange = true; // Usually, but sometimes not :)
 15+ private $mUser = null; // The user requesting the reset
1516
1617 public function __construct() {
1718 parent::__construct( 'Resetpass' );
1819 }
 20+
 21+ /**
 22+ * Sometimes the user requesting the password change is not $wgUser
 23+ * See bug 17722
 24+ * @param User $usr
 25+ */
 26+ public function setUser( $usr ) {
 27+ $this->mUser = $usr;
 28+ }
1929
2030 /**
2131 * Main execution point
@@ -28,6 +38,10 @@
2939 $this->mRetype = $wgRequest->getVal( 'wpRetype' );
3040 $this->mComment = $wgRequest->getVal( 'wpComment' );
3141
 42+ if ( is_null( $this->mUser ) ) {
 43+ $this->mUser = $wgUser;
 44+ }
 45+
3246 $this->setHeaders();
3347 $this->outputHeader();
3448
@@ -38,25 +52,25 @@
3953
4054 // Default to our own username when not given one
4155 if ( !$this->mUserName ) {
42 - $this->mUserName = $wgUser->getName();
 56+ $this->mUserName = $this->mUser->getName();
4357 }
4458
4559 // Are we changing our own?
46 - if ( $wgUser->getName() != $this->mUserName ) {
 60+ if ( $this->mUser->getName() != $this->mUserName ) {
4761 $this->mSelfChange = false; // We're changing someone else
4862 }
4963
50 - if( !$wgRequest->wasPosted() && !$wgUser->isLoggedIn() ) {
 64+ if( !$wgRequest->wasPosted() && !$this->mUser->isLoggedIn() ) {
5165 $this->error( wfMsg( 'resetpass-no-info' ) );
5266 return;
5367 }
5468
55 - if ( !$this->mSelfChange && !$wgUser->isAllowed( 'reset-passwords' ) ) {
 69+ if ( !$this->mSelfChange && !$this->mUser->isAllowed( 'reset-passwords' ) ) {
5670 $this->error( wfMsg( 'resetpass-no-others' ) );
5771 return;
5872 }
5973
60 - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal('token') ) ) {
 74+ if( $wgRequest->wasPosted() && $this->mUser->matchEditToken( $wgRequest->getVal('token') ) ) {
6175 try {
6276 $this->attemptReset( $this->mNewpass, $this->mRetype );
6377 $wgOut->addWikiMsg( 'resetpass_success' );
@@ -96,14 +110,14 @@
97111
98112 $wgOut->disallowUserJs();
99113
100 - if ( $wgUser->isAllowed( 'reset-passwords') ) {
 114+ if ( $this->mUser->isAllowed( 'reset-passwords') ) {
101115 $wgOut->addScriptFile( 'changepassword.js' );
102116 }
103117
104118 $self = SpecialPage::getTitleFor( 'Resetpass' );
105119
106120 $rememberMe = '';
107 - if ( !$wgUser->isLoggedIn() ) {
 121+ if ( !$this->mUser->isLoggedIn() ) {
108122 $rememberMe = '<tr>' .
109123 '<td></td>' .
110124 '<td class="mw-input">' .
@@ -124,16 +138,16 @@
125139 'method' => 'post',
126140 'action' => $self->getLocalUrl(),
127141 'id' => 'mw-resetpass-form' ) ) .
128 - Xml::hidden( 'token', $wgUser->editToken() ) .
 142+ Xml::hidden( 'token', $this->mUser->editToken() ) .
129143 Xml::hidden( 'returnto', $wgRequest->getVal( 'returnto' ) ) .
130144 wfMsgExt( 'resetpass_text', array( 'parse' ) ) .
131145 Xml::openElement( 'table', array( 'id' => 'mw-resetpass-table' ) );
132146 $formElements = array(
133 - array( 'wpName', 'username', 'text', $this->mUserName, $wgUser->isAllowed( 'reset-passwords' ) ),
 147+ array( 'wpName', 'username', 'text', $this->mUserName, $this->mUser->isAllowed( 'reset-passwords' ) ),
134148 array( 'wpPassword', $oldpassMsg, 'password', $this->mOldpass, $this->mSelfChange ),
135149 array( 'wpNewPassword', 'newpassword', 'password', '', true ),
136150 array( 'wpRetype', 'retypenew', 'password', '', true ) );
137 - if ( $wgUser->isAllowed( 'reset-passwords' ) && $this->mSelfChange )
 151+ if ( $this->mUser->isAllowed( 'reset-passwords' ) && $this->mSelfChange )
138152 $formElements[] = array( 'wpComment', 'resetpass-comment', 'text', $this->mComment, true );
139153 $s .= $this->pretty( $formElements ) .
140154 $rememberMe .

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r47976(bug 17722) Fix regression where users are unable to change temporary passwordsdemon13:45, 3 March 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   01:17, 25 March 2009

This ain't fixed.

Status & tagging log