r48780 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48779‎ | r48780 | r48781 >
Date:02:27, 25 March 2009
Author:werdna
Status:ok (Comments)
Tags:
Comment:
Revert r47569 and subsequent related revisions. These still break logging in with temporary passwords despite two attempts to fix the issue.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialResetpass.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -163,7 +163,6 @@
164164 'proxyunbannable',
165165 'purge',
166166 'read',
167 - 'reset-passwords',
168167 'reupload',
169168 'reupload-shared',
170169 'rollback',
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1255,8 +1255,6 @@
12561256 // Permission to change users' group assignments
12571257 $wgGroupPermissions['bureaucrat']['userrights'] = true;
12581258 $wgGroupPermissions['bureaucrat']['noratelimit'] = true;
1259 -// Permission to change users' passwords
1260 -# $wgGroupPermissions['bureaucrat']['reset-passwords'] = true;
12611259 // Permission to change users' groups assignments across wikis
12621260 #$wgGroupPermissions['bureaucrat']['userrights-interwiki'] = true;
12631261 // Permission to export pages including linked pages regardless of $wgExportMaxLinkDepth
@@ -1471,7 +1469,7 @@
14721470 * to ensure that client-side caches don't keep obsolete copies of global
14731471 * styles.
14741472 */
1475 -$wgStyleVersion = '207';
 1473+$wgStyleVersion = '206';
14761474
14771475
14781476 # Server-side caching:
@@ -2873,7 +2871,6 @@
28742872 'patrol',
28752873 'merge',
28762874 'suppress',
2877 - 'password',
28782875 );
28792876
28802877 /**
@@ -2928,7 +2925,6 @@
29292926 'patrol' => 'patrol-log-page',
29302927 'merge' => 'mergelog',
29312928 'suppress' => 'suppressionlog',
2932 - 'password' => 'resetpass-log'
29332929 );
29342930
29352931 /**
@@ -2949,7 +2945,6 @@
29502946 'patrol' => 'patrol-log-header',
29512947 'merge' => 'mergelogpagetext',
29522948 'suppress' => 'suppressionlogtext',
2953 - 'password' => 'resetpass-logtext',
29542949 );
29552950
29562951 /**
@@ -2985,7 +2980,6 @@
29862981 'suppress/delete' => 'suppressedarticle',
29872982 'suppress/block' => 'blocklogentry',
29882983 'suppress/reblock' => 'reblock-logentry',
2989 - 'password/reset' => 'resetpass-logentry'
29902984 );
29912985
29922986 /**
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -589,8 +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 ) );
594 - $reset->execute( $this->mName );
 593+ $reset->execute( null );
595594 }
596595
597596 /**
Index: trunk/phase3/includes/specials/SpecialResetpass.php
@@ -9,22 +9,9 @@
1010 * @ingroup SpecialPage
1111 */
1212 class SpecialResetpass extends SpecialPage {
13 -
14 - private $mSelfChange = true; // Usually, but sometimes not :)
15 - private $mUser = null; // The user requesting the reset
16 -
1713 public function __construct() {
1814 parent::__construct( 'Resetpass' );
1915 }
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 - }
2916
3017 /**
3118 * Main execution point
@@ -32,16 +19,11 @@
3320 function execute( $par ) {
3421 global $wgUser, $wgAuth, $wgOut, $wgRequest;
3522
36 - $this->mUserName = $wgRequest->getVal( 'wpName', $par );
 23+ $this->mUserName = $wgRequest->getVal( 'wpName' );
3724 $this->mOldpass = $wgRequest->getVal( 'wpPassword' );
3825 $this->mNewpass = $wgRequest->getVal( 'wpNewPassword' );
3926 $this->mRetype = $wgRequest->getVal( 'wpRetype' );
40 - $this->mComment = $wgRequest->getVal( 'wpComment' );
4127
42 - if ( is_null( $this->mUser ) ) {
43 - $this->mUser = $wgUser;
44 - }
45 -
4628 $this->setHeaders();
4729 $this->outputHeader();
4830
@@ -49,33 +31,17 @@
5032 $this->error( wfMsg( 'resetpass_forbidden' ) );
5133 return;
5234 }
53 -
54 - // Default to our own username when not given one
55 - if ( !$this->mUserName ) {
56 - $this->mUserName = $this->mUser->getName();
57 - }
58 -
59 - // Are we changing our own?
60 - if ( $this->mUser->getName() != $this->mUserName ) {
61 - $this->mSelfChange = false; // We're changing someone else
62 - }
6335
64 - if( !$wgRequest->wasPosted() && !$this->mUser->isLoggedIn() ) {
 36+ if( !$wgRequest->wasPosted() && !$wgUser->isLoggedIn() ) {
6537 $this->error( wfMsg( 'resetpass-no-info' ) );
6638 return;
6739 }
6840
69 - if ( !$this->mSelfChange && !$this->mUser->isAllowed( 'reset-passwords' ) ) {
70 - $this->error( wfMsg( 'resetpass-no-others' ) );
71 - return;
72 - }
73 -
74 - if( $wgRequest->wasPosted() && $this->mUser->matchEditToken( $wgRequest->getVal('token') ) ) {
 41+ if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal('token') ) ) {
7542 try {
7643 $this->attemptReset( $this->mNewpass, $this->mRetype );
7744 $wgOut->addWikiMsg( 'resetpass_success' );
78 - // Only attempt this login session if we're changing our own password
79 - if( $this->mSelfChange && !$wgUser->isLoggedIn() ) {
 45+ if( !$wgUser->isLoggedIn() ) {
8046 $data = array(
8147 'action' => 'submitlogin',
8248 'wpName' => $this->mUserName,
@@ -109,15 +75,13 @@
11076 global $wgOut, $wgUser, $wgRequest;
11177
11278 $wgOut->disallowUserJs();
113 -
114 - if ( $this->mUser->isAllowed( 'reset-passwords') ) {
115 - $wgOut->addScriptFile( 'changepassword.js' );
116 - }
11779
11880 $self = SpecialPage::getTitleFor( 'Resetpass' );
119 -
 81+ if ( !$this->mUserName ) {
 82+ $this->mUserName = $wgUser->getName();
 83+ }
12084 $rememberMe = '';
121 - if ( !$this->mUser->isLoggedIn() ) {
 85+ if ( !$wgUser->isLoggedIn() ) {
12286 $rememberMe = '<tr>' .
12387 '<td></td>' .
12488 '<td class="mw-input">' .
@@ -132,24 +96,24 @@
13397 $oldpassMsg = 'oldpassword';
13498 $submitMsg = 'resetpass-submit-loggedin';
13599 }
136 - $s = Xml::fieldset( wfMsg( 'resetpass_header' ) ) .
 100+ $wgOut->addHTML(
 101+ Xml::fieldset( wfMsg( 'resetpass_header' ) ) .
137102 Xml::openElement( 'form',
138103 array(
139104 'method' => 'post',
140105 'action' => $self->getLocalUrl(),
141106 'id' => 'mw-resetpass-form' ) ) .
142 - Xml::hidden( 'token', $this->mUser->editToken() ) .
 107+ Xml::hidden( 'token', $wgUser->editToken() ) .
 108+ Xml::hidden( 'wpName', $this->mUserName ) .
143109 Xml::hidden( 'returnto', $wgRequest->getVal( 'returnto' ) ) .
144110 wfMsgExt( 'resetpass_text', array( 'parse' ) ) .
145 - Xml::openElement( 'table', array( 'id' => 'mw-resetpass-table' ) );
146 - $formElements = array(
147 - array( 'wpName', 'username', 'text', $this->mUserName, $this->mUser->isAllowed( 'reset-passwords' ) ),
148 - array( 'wpPassword', $oldpassMsg, 'password', $this->mOldpass, $this->mSelfChange ),
149 - array( 'wpNewPassword', 'newpassword', 'password', '', true ),
150 - array( 'wpRetype', 'retypenew', 'password', '', true ) );
151 - if ( $this->mUser->isAllowed( 'reset-passwords' ) && $this->mSelfChange )
152 - $formElements[] = array( 'wpComment', 'resetpass-comment', 'text', $this->mComment, true );
153 - $s .= $this->pretty( $formElements ) .
 111+ Xml::openElement( 'table', array( 'id' => 'mw-resetpass-table' ) ) .
 112+ $this->pretty( array(
 113+ array( 'wpName', 'username', 'text', $this->mUserName ),
 114+ array( 'wpPassword', $oldpassMsg, 'password', $this->mOldpass ),
 115+ array( 'wpNewPassword', 'newpassword', 'password', '' ),
 116+ array( 'wpRetype', 'retypenew', 'password', '' ),
 117+ ) ) .
154118 $rememberMe .
155119 '<tr>' .
156120 '<td></td>' .
@@ -159,23 +123,28 @@
160124 '</tr>' .
161125 Xml::closeElement( 'table' ) .
162126 Xml::closeElement( 'form' ) .
163 - Xml::closeElement( 'fieldset' );
164 - $wgOut->addHtml( $s );
 127+ Xml::closeElement( 'fieldset' )
 128+ );
165129 }
166130
167131 function pretty( $fields ) {
168132 $out = '';
169133 foreach( $fields as $list ) {
170 - list( $name, $label, $type, $value, $enabled ) = $list;
171 - $params = array( 'id' => $name, 'type' => $type );
172 - if ( !$enabled )
173 - $params['disabled'] = 'disabled';
174 - $field = Xml::input( $name, 20, $value, $params );
 134+ list( $name, $label, $type, $value ) = $list;
 135+ if( $type == 'text' ) {
 136+ $field = htmlspecialchars( $value );
 137+ } else {
 138+ $field = Xml::input( $name, 20, $value,
 139+ array( 'id' => $name, 'type' => $type ) );
 140+ }
175141 $out .= '<tr>';
176 - $out .= '<td class="mw-label">';
177 - $out .= Xml::label( wfMsg( $label ), $name );
 142+ $out .= "<td class='mw-label'>";
 143+ if ( $type != 'text' )
 144+ $out .= Xml::label( wfMsg( $label ), $name );
 145+ else
 146+ $out .= wfMsg( $label );
178147 $out .= '</td>';
179 - $out .= '<td class="mw-input">';
 148+ $out .= "<td class='mw-input'>";
180149 $out .= $field;
181150 $out .= '</td>';
182151 $out .= '</tr>';
@@ -197,13 +166,11 @@
198167 throw new PasswordError( wfMsg( 'badretype' ) );
199168 }
200169
201 - if ( $this->mSelfChange ) {
202 - if( !$user->checkTemporaryPassword($this->mOldpass) && !$user->checkPassword($this->mOldpass) ) {
203 - wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'wrongpassword' ) );
204 - throw new PasswordError( wfMsg( 'resetpass-wrong-oldpass' ) );
205 - }
 170+ if( !$user->checkTemporaryPassword($this->mOldpass) && !$user->checkPassword($this->mOldpass) ) {
 171+ wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'wrongpassword' ) );
 172+ throw new PasswordError( wfMsg( 'resetpass-wrong-oldpass' ) );
206173 }
207 -
 174+
208175 try {
209176 $user->setPassword( $this->mNewpass );
210177 wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'success' ) );
@@ -214,14 +181,7 @@
215182 return;
216183 }
217184
218 - if ( !$this->mSelfChange ) {
219 - $log = new LogPage( 'password' );
220 - $log->addEntry( 'reset', $user->getUserPage(), $this->mComment );
221 - } else {
222 - // Only set cookies if it was a self-change
223 - $user->setCookies();
224 - }
225 -
 185+ $user->setCookies();
226186 $user->saveSettings();
227187 }
228188 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1018,7 +1018,6 @@
10191019 'resetpass-wrong-oldpass' => 'Invalid temporary or current password.
10201020 You may have already successfully changed your password or requested a new temporary password.',
10211021 'resetpass-temp-password' => 'Temporary password:',
1022 -'resetpass-no-others' => 'You cannot reset the password for other users.',
10231022 'resetpass-log' => 'Password resets log',
10241023 'resetpass-logtext' => 'Below is a log of users who have had their password reset by an administrator.',
10251024 'resetpass-logentry' => 'changed the password for $1',
Index: trunk/phase3/RELEASE-NOTES
@@ -117,11 +117,8 @@
118118 * Special:ListUsers: Sort list of usergroups by alphabet
119119 * (bug 16762) Special:Movepage now shows a list of subpages when possible
120120 * (bug 17585) Hide legend on Special:Specialpages from non-privileged users
121 -* (bug 15876) Users with 'reset-passwords' right can change the passwords of
122 - other users.
123121 * Add an ID if 'missingsummary' is triggered to allow styling of the summary
124122 line
125 -* Add logging to password resets if not resetting your own
126123 * Added $wgUseTagFilter to control enabling of filter-by-change-tag
127124 * (bug 17291) MediaWiki:Nocontribs now has an optional $1 parameter for the
128125 username

Follow-up revisions

RevisionCommit summaryAuthorDate
r48789Follow up r48780: Remove message from maintenance script tooraymond07:17, 25 March 2009
r78536Rm unused javascript added in r47637 (follow up to r47569) and not reverted w...happy-melon16:04, 17 December 2010
r95597Remove a message for a feature introduced with r47569 and reverted with r48780.raymond11:01, 27 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r47569ChangePassword fixes:...demon18:35, 20 February 2009

Comments

#Comment by Raymond (talk | contribs)   07:20, 25 March 2009

Follow up in r48789: Remove unused message from maintenance script too

Status & tagging log