r47637 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47636‎ | r47637 | r47638 >
Date:22:27, 21 February 2009
Author:demon
Status:reverted (Comments)
Tags:
Comment:
Add logging to password resets per request on code review. Also a little javascript thing for disable/enable of relevant text boxes if you change the name to/from your own.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialResetpass.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)
  • /trunk/phase3/skins/common/changepassword.js (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -462,6 +462,10 @@
463463 'resetpass-wrong-oldpass',
464464 'resetpass-temp-password',
465465 'resetpass-no-others',
 466+ 'resetpass-log',
 467+ 'resetpass-logtext',
 468+ 'resetpass-logentry',
 469+ 'resetpass-comment',
466470 ),
467471 'toolbar' => array(
468472 'bold_sample',
Index: trunk/phase3/skins/common/changepassword.js
@@ -0,0 +1,32 @@
 2+
 3+function onNameChange() {
 4+ if ( wgUserName != document.getElementById('wpName').value ) {
 5+ document.getElementById('wpPassword').disabled = true;
 6+ document.getElementById('wpComment').disabled = false;
 7+ } else {
 8+ document.getElementById('wpPassword').disabled = false;
 9+ document.getElementById('wpComment').disabled = true;
 10+ }
 11+}
 12+
 13+function onNameChangeHook() {
 14+ document.getElementById( 'wpName' ).onblur = onNameChange;
 15+}
 16+
 17+addOnloadHook( onNameChangeHook );
 18+
 19+function onNameChange() {
 20+ if ( wgUserName != document.getElementById('wpName').value ) {
 21+ document.getElementById('wpPassword').disabled = true;
 22+ document.getElementById('wpComment').disabled = false;
 23+ } else {
 24+ document.getElementById('wpPassword').disabled = false;
 25+ document.getElementById('wpComment').disabled = true;
 26+ }
 27+}
 28+
 29+function onNameChangeHook() {
 30+ document.getElementById( 'wpName' ).onblur = onNameChange;
 31+}
 32+
 33+addOnloadHook( onNameChangeHook );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1469,7 +1469,7 @@
14701470 * to ensure that client-side caches don't keep obsolete copies of global
14711471 * styles.
14721472 */
1473 -$wgStyleVersion = '206';
 1473+$wgStyleVersion = '207';
14741474
14751475
14761476 # Server-side caching:
@@ -2843,6 +2843,7 @@
28442844 'patrol',
28452845 'merge',
28462846 'suppress',
 2847+ 'password',
28472848 );
28482849
28492850 /**
@@ -2897,6 +2898,7 @@
28982899 'patrol' => 'patrol-log-page',
28992900 'merge' => 'mergelog',
29002901 'suppress' => 'suppressionlog',
 2902+ 'password' => 'resetpass-log'
29012903 );
29022904
29032905 /**
@@ -2917,6 +2919,7 @@
29182920 'patrol' => 'patrol-log-header',
29192921 'merge' => 'mergelogpagetext',
29202922 'suppress' => 'suppressionlogtext',
 2923+ 'password' => 'resetpass-logtext',
29212924 );
29222925
29232926 /**
@@ -2952,6 +2955,7 @@
29532956 'suppress/delete' => 'suppressedarticle',
29542957 'suppress/block' => 'blocklogentry',
29552958 'suppress/reblock' => 'reblock-logentry',
 2959+ 'password/reset' => 'resetpass-logentry'
29562960 );
29572961
29582962 /**
Index: trunk/phase3/includes/specials/SpecialResetpass.php
@@ -26,6 +26,7 @@
2727 $this->mOldpass = $wgRequest->getVal( 'wpPassword' );
2828 $this->mNewpass = $wgRequest->getVal( 'wpNewPassword' );
2929 $this->mRetype = $wgRequest->getVal( 'wpRetype' );
 30+ $this->mComment = $wgRequest->getVal( 'wpComment' );
3031
3132 $this->setHeaders();
3233 $this->outputHeader();
@@ -94,6 +95,10 @@
9596 global $wgOut, $wgUser, $wgRequest;
9697
9798 $wgOut->disallowUserJs();
 99+
 100+ if ( $wgUser->isAllowed( 'reset-passwords') ) {
 101+ $wgOut->addScriptFile( 'changepassword.js' );
 102+ }
98103
99104 $self = SpecialPage::getTitleFor( 'Resetpass' );
100105
@@ -113,8 +118,7 @@
114119 $oldpassMsg = 'oldpassword';
115120 $submitMsg = 'resetpass-submit-loggedin';
116121 }
117 - $wgOut->addHTML(
118 - Xml::fieldset( wfMsg( 'resetpass_header' ) ) .
 122+ $s = Xml::fieldset( wfMsg( 'resetpass_header' ) ) .
119123 Xml::openElement( 'form',
120124 array(
121125 'method' => 'post',
@@ -123,13 +127,15 @@
124128 Xml::hidden( 'token', $wgUser->editToken() ) .
125129 Xml::hidden( 'returnto', $wgRequest->getVal( 'returnto' ) ) .
126130 wfMsgExt( 'resetpass_text', array( 'parse' ) ) .
127 - Xml::openElement( 'table', array( 'id' => 'mw-resetpass-table' ) ) .
128 - $this->pretty( array(
 131+ Xml::openElement( 'table', array( 'id' => 'mw-resetpass-table' ) );
 132+ $formElements = array(
129133 array( 'wpName', 'username', 'text', $this->mUserName, $wgUser->isAllowed( 'reset-passwords' ) ),
130134 array( 'wpPassword', $oldpassMsg, 'password', $this->mOldpass, $this->mSelfChange ),
131135 array( 'wpNewPassword', 'newpassword', 'password', '', true ),
132 - array( 'wpRetype', 'retypenew', 'password', '', true ),
133 - ) ) .
 136+ array( 'wpRetype', 'retypenew', 'password', '', true ) );
 137+ if ( $wgUser->isAllowed( 'reset-passwords' ) && $this->mSelfChange )
 138+ $formElements[] = array( 'wpComment', 'resetpass-comment', 'text', $this->mComment, true );
 139+ $s .= $this->pretty( $formElements ) .
134140 $rememberMe .
135141 '<tr>' .
136142 '<td></td>' .
@@ -139,8 +145,8 @@
140146 '</tr>' .
141147 Xml::closeElement( 'table' ) .
142148 Xml::closeElement( 'form' ) .
143 - Xml::closeElement( 'fieldset' )
144 - );
 149+ Xml::closeElement( 'fieldset' );
 150+ $wgOut->addHtml( $s );
145151 }
146152
147153 function pretty( $fields ) {
@@ -183,7 +189,7 @@
184190 throw new PasswordError( wfMsg( 'resetpass-wrong-oldpass' ) );
185191 }
186192 }
187 -
 193+
188194 try {
189195 $user->setPassword( $this->mNewpass );
190196 wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'success' ) );
@@ -194,6 +200,11 @@
195201 return;
196202 }
197203
 204+ if ( !$this->mSelfChange ) {
 205+ $log = new LogPage( 'password' );
 206+ $log->addEntry( 'reset', $user->getUserPage(), $this->mComment );
 207+ }
 208+
198209 $user->setCookies();
199210 $user->saveSettings();
200211 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1017,6 +1017,10 @@
10181018 You may have already successfully changed your password or requested a new temporary password.',
10191019 'resetpass-temp-password' => 'Temporary password:',
10201020 'resetpass-no-others' => 'You cannot reset the password for other users.',
 1021+'resetpass-log' => 'Password resets',
 1022+'resetpass-logtext' => 'Below is a log of users who have had their password reset by a bureaucrat',
 1023+'resetpass-logentry' => 'changed the password for $1',
 1024+'resetpass-comment' => 'Reason for password reset',
10211025
10221026 # Edit page toolbar
10231027 'bold_sample' => 'Bold text',

Follow-up revisions

RevisionCommit summaryAuthorDate
r47641Minor tweaks to messages for password reset feature introduced in r47637siebrand22:52, 21 February 2009
r78536Rm unused javascript added in r47637 (follow up to r47569) and not reverted w...happy-melon16:04, 17 December 2010

Comments

#Comment by Siebrand (talk | contribs)   22:57, 21 February 2009

Some fixes made in r47641 and 47642

Status & tagging log