Index: trunk/phase3/includes/specials/SpecialUserlogin.php |
— | — | @@ -589,6 +589,7 @@ |
590 | 590 | global $wgOut; |
591 | 591 | $wgOut->addHTML( Xml::element('p', array( 'class' => 'error' ), $error ) ); |
592 | 592 | $reset = new SpecialResetpass(); |
| 593 | + $reset->setUser( User::newFromName( $this->mName ) ); |
593 | 594 | $reset->execute( $this->mName ); |
594 | 595 | } |
595 | 596 | |
Index: trunk/phase3/includes/specials/SpecialResetpass.php |
— | — | @@ -11,10 +11,20 @@ |
12 | 12 | class SpecialResetpass extends SpecialPage { |
13 | 13 | |
14 | 14 | private $mSelfChange = true; // Usually, but sometimes not :) |
| 15 | + private $mUser = null; // The user requesting the reset |
15 | 16 | |
16 | 17 | public function __construct() { |
17 | 18 | parent::__construct( 'Resetpass' ); |
18 | 19 | } |
| 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 | + } |
19 | 29 | |
20 | 30 | /** |
21 | 31 | * Main execution point |
— | — | @@ -28,6 +38,10 @@ |
29 | 39 | $this->mRetype = $wgRequest->getVal( 'wpRetype' ); |
30 | 40 | $this->mComment = $wgRequest->getVal( 'wpComment' ); |
31 | 41 | |
| 42 | + if ( is_null( $this->mUser ) ) { |
| 43 | + $this->mUser = $wgUser; |
| 44 | + } |
| 45 | + |
32 | 46 | $this->setHeaders(); |
33 | 47 | $this->outputHeader(); |
34 | 48 | |
— | — | @@ -38,25 +52,25 @@ |
39 | 53 | |
40 | 54 | // Default to our own username when not given one |
41 | 55 | if ( !$this->mUserName ) { |
42 | | - $this->mUserName = $wgUser->getName(); |
| 56 | + $this->mUserName = $this->mUser->getName(); |
43 | 57 | } |
44 | 58 | |
45 | 59 | // Are we changing our own? |
46 | | - if ( $wgUser->getName() != $this->mUserName ) { |
| 60 | + if ( $this->mUser->getName() != $this->mUserName ) { |
47 | 61 | $this->mSelfChange = false; // We're changing someone else |
48 | 62 | } |
49 | 63 | |
50 | | - if( !$wgRequest->wasPosted() && !$wgUser->isLoggedIn() ) { |
| 64 | + if( !$wgRequest->wasPosted() && !$this->mUser->isLoggedIn() ) { |
51 | 65 | $this->error( wfMsg( 'resetpass-no-info' ) ); |
52 | 66 | return; |
53 | 67 | } |
54 | 68 | |
55 | | - if ( !$this->mSelfChange && !$wgUser->isAllowed( 'reset-passwords' ) ) { |
| 69 | + if ( !$this->mSelfChange && !$this->mUser->isAllowed( 'reset-passwords' ) ) { |
56 | 70 | $this->error( wfMsg( 'resetpass-no-others' ) ); |
57 | 71 | return; |
58 | 72 | } |
59 | 73 | |
60 | | - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal('token') ) ) { |
| 74 | + if( $wgRequest->wasPosted() && $this->mUser->matchEditToken( $wgRequest->getVal('token') ) ) { |
61 | 75 | try { |
62 | 76 | $this->attemptReset( $this->mNewpass, $this->mRetype ); |
63 | 77 | $wgOut->addWikiMsg( 'resetpass_success' ); |
— | — | @@ -96,14 +110,14 @@ |
97 | 111 | |
98 | 112 | $wgOut->disallowUserJs(); |
99 | 113 | |
100 | | - if ( $wgUser->isAllowed( 'reset-passwords') ) { |
| 114 | + if ( $this->mUser->isAllowed( 'reset-passwords') ) { |
101 | 115 | $wgOut->addScriptFile( 'changepassword.js' ); |
102 | 116 | } |
103 | 117 | |
104 | 118 | $self = SpecialPage::getTitleFor( 'Resetpass' ); |
105 | 119 | |
106 | 120 | $rememberMe = ''; |
107 | | - if ( !$wgUser->isLoggedIn() ) { |
| 121 | + if ( !$this->mUser->isLoggedIn() ) { |
108 | 122 | $rememberMe = '<tr>' . |
109 | 123 | '<td></td>' . |
110 | 124 | '<td class="mw-input">' . |
— | — | @@ -124,16 +138,16 @@ |
125 | 139 | 'method' => 'post', |
126 | 140 | 'action' => $self->getLocalUrl(), |
127 | 141 | 'id' => 'mw-resetpass-form' ) ) . |
128 | | - Xml::hidden( 'token', $wgUser->editToken() ) . |
| 142 | + Xml::hidden( 'token', $this->mUser->editToken() ) . |
129 | 143 | Xml::hidden( 'returnto', $wgRequest->getVal( 'returnto' ) ) . |
130 | 144 | wfMsgExt( 'resetpass_text', array( 'parse' ) ) . |
131 | 145 | Xml::openElement( 'table', array( 'id' => 'mw-resetpass-table' ) ); |
132 | 146 | $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' ) ), |
134 | 148 | array( 'wpPassword', $oldpassMsg, 'password', $this->mOldpass, $this->mSelfChange ), |
135 | 149 | array( 'wpNewPassword', 'newpassword', 'password', '', true ), |
136 | 150 | array( 'wpRetype', 'retypenew', 'password', '', true ) ); |
137 | | - if ( $wgUser->isAllowed( 'reset-passwords' ) && $this->mSelfChange ) |
| 151 | + if ( $this->mUser->isAllowed( 'reset-passwords' ) && $this->mSelfChange ) |
138 | 152 | $formElements[] = array( 'wpComment', 'resetpass-comment', 'text', $this->mComment, true ); |
139 | 153 | $s .= $this->pretty( $formElements ) . |
140 | 154 | $rememberMe . |