r28418 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r28417‎ | r28418 | r28419 >
Date:20:19, 12 December 2007
Author:tlaqua
Status:old
Tags:
Comment:
Added GetBlockedStatus hook
* Disallows disabled accounts requesting a new password via email
* Forcefully logs out users who have had their accounts disabled
* TODO: Fix logon error message - because the GetBlockedStatus hook us used, the displayed message is 'blocked-mailpassword'
Modified paths:
  • /trunk/extensions/PasswordReset/PasswordReset.i18n.php (modified) (history)
  • /trunk/extensions/PasswordReset/PasswordReset.php (modified) (history)
  • /trunk/extensions/PasswordReset/PasswordReset_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PasswordReset/PasswordReset_body.php
@@ -167,4 +167,41 @@
168168
169169 return true;
170170 }
 171+
 172+ function GetBlockedStatus(&$user) {
 173+ global $wgTitle;
 174+
 175+ if ($wgTitle->isSpecial('Userlogin')) {
 176+ global $wgRequest;
 177+ if ($wgRequest->wasPosted()) {
 178+ $name = $wgRequest->getText('wpName');
 179+ if ($name <> '') {
 180+
 181+ $dbr = wfGetDB( DB_SLAVE );
 182+ $res = $dbr->select( 'user',
 183+ array( 'user_password' ),
 184+ array( 'user_name' => $name ),
 185+ __METHOD__ );
 186+
 187+ while ( $row = $dbr->fetchObject( $res ) ) {
 188+ if ($row->user_password == 'DISABLED') {
 189+ $user->mBlockedby = 1;
 190+ $user->mBlockreason = wfMsg( 'passwordreset-accountdisabled' );
 191+ }
 192+ }
 193+ }
 194+ }
 195+ } elseif ( $user->isLoggedIn() ) {
 196+ if ($user->mPassword == 'DISABLED') {
 197+ global $wgOut;
 198+ //mean, I know.
 199+ $user->logout();
 200+ $wgOut->redirect( Title::newMainPage()->escapeFullURL());
 201+ }
 202+ } else {
 203+ echo "not logged in (" . $user->getID() . ")";
 204+ }
 205+
 206+ return true;
 207+ }
171208 }
Index: trunk/extensions/PasswordReset/PasswordReset.i18n.php
@@ -18,7 +18,8 @@
1919 'passwordreset-success' => 'Password has been reset for user_id: $1',
2020 'passwordreset-disableuser' => 'Disable User Account?',
2121 'passwordreset-disableuserexplain' => '(sets an invalid password hash - user can\'t login)',
22 - 'passwordreset-disablesuccess' => 'User account has been disabled (user_id: $1)'
 22+ 'passwordreset-disablesuccess' => 'User account has been disabled (user_id: $1)',
 23+ 'passwordreset-accountdisabled' => 'Account has been disabled'
2324 ),
2425
2526 'af' => array(
Index: trunk/extensions/PasswordReset/PasswordReset.php
@@ -10,11 +10,11 @@
1111 }
1212
1313 $wgExtensionCredits['specialpage'][] = array(
14 - 'name'=>'Password Reset',
15 - 'url'=>'http://www.mediawiki.org/wiki/Extension:Password_Reset',
16 - 'author'=>'Tim Laqua',
17 - 'description'=>"Resets Wiki user's passwords - requires 'passwordreset' privileges",
18 - 'version'=>'1.3',
 14+ 'name'=>'Password Reset',
 15+ 'url'=>'http://www.mediawiki.org/wiki/Extension:Password_Reset',
 16+ 'author'=>'Tim Laqua',
 17+ 'description'=>"Resets Wiki user's passwords - requires 'passwordreset' privileges",
 18+ 'version'=>'1.4'
1919 );
2020
2121 $wgAutoloadClasses['PasswordReset'] = dirname(__FILE__) . '/PasswordReset_body.php';
@@ -26,3 +26,5 @@
2727 } else {
2828 $wgHooks['LoadAllMessages'][] = 'PasswordReset::loadMessages';
2929 }
 30+
 31+$wgHooks['GetBlockedStatus'][] = 'PasswordReset::GetBlockedStatus';

Status & tagging log