r40617 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40616‎ | r40617 | r40618 >
Date:21:23, 8 September 2008
Author:ialex
Status:old
Tags:
Comment:
Call SpecialPage::setHeaders() when the request is invalid at Special:AutoLogin
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.i18n.php (modified) (history)
  • /trunk/extensions/CentralAuth/SpecialAutoLogin.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/SpecialAutoLogin.php
@@ -8,24 +8,24 @@
99 *
1010 * @addtogroup Extensions
1111 */
12 -
13 -class SpecialAutoLogin extends UnlistedSpecialPage
14 -{
 12+class SpecialAutoLogin extends UnlistedSpecialPage {
 13+
1514 function __construct() {
1615 parent::__construct('AutoLogin');
1716 }
18 -
 17+
1918 function execute( $par ) {
2019 global $wgRequest, $wgOut, $wgUser, $wgMemc, $IP;
21 -
22 - $tempToken = $wgRequest->getVal('token');
 20+
 21+ $tempToken = $wgRequest->getVal( 'token' );
2322 $logout = $wgRequest->getBool( 'logout' );
2423
2524 # Don't cache error messages
2625 $wgOut->enableClientCache( false );
2726
28 - if (strlen($tempToken) == 0) {
 27+ if( strlen( $tempToken ) == 0 ) {
2928 wfLoadExtensionMessages( 'SpecialCentralAuth' );
 29+ $this->setHeaders();
3030 $wgOut->addWikiMsg( 'centralauth-autologin-desc' );
3131 return;
3232 }
@@ -34,9 +34,11 @@
3535 $data = $wgMemc->get( $key );
3636 $wgMemc->delete( $key );
3737
38 - if ( !$data ) {
 38+ if( !$data ) {
3939 $msg = 'Token is invalid or has expired';
4040 wfDebug( __METHOD__.": $msg\n" );
 41+ wfLoadExtensionMessages( 'SpecialCentralAuth' );
 42+ $this->setHeaders();
4143 $wgOut->addWikiText( $msg );
4244 return;
4345 }
@@ -44,22 +46,24 @@
4547 $userName = $data['userName'];
4648 $token = $data['token'];
4749 $remember = $data['remember'];
48 -
49 - #die( print_r( $data, true ));
50 -
51 - if ($data['wiki'] != wfWikiID()) {
 50+
 51+ if( $data['wiki'] != wfWikiID() ) {
5252 $msg = 'Bad token (wrong wiki)';
5353 wfDebug( __METHOD__.": $msg\n" );
 54+ wfLoadExtensionMessages( 'SpecialCentralAuth' );
 55+ $this->setHeaders();
5456 $wgOut->addWikiText( $msg );
5557 return;
5658 }
57 -
 59+
5860 $centralUser = new CentralAuthUser( $userName );
5961 $loginResult = $centralUser->authenticateWithToken( $token );
60 -
61 - if ($loginResult != 'ok') {
 62+
 63+ if( $loginResult != 'ok' ) {
6264 $msg = "Bad token: $loginResult";
6365 wfDebug( __METHOD__.": $msg\n" );
 66+ wfLoadExtensionMessages( 'SpecialCentralAuth' );
 67+ $this->setHeaders();
6468 $wgOut->addWikiText( $msg );
6569 return;
6670 }
@@ -68,7 +72,7 @@
6973 if ( $logout ) {
7074 $centralUser->deleteGlobalCookies();
7175 } else {
72 - $centralUser->setGlobalCookies($remember);
 76+ $centralUser->setGlobalCookies( $remember );
7377 }
7478
7579 $wgOut->disable();
@@ -78,7 +82,7 @@
7983 header( 'Content-Type: image/png' );
8084
8185 global $wgCentralAuthLoginIcon;
82 - if ( $wgCentralAuthLoginIcon ) {
 86+ if( $wgCentralAuthLoginIcon ) {
8387 readfile( $wgCentralAuthLoginIcon );
8488 } else {
8589 readfile( dirname(__FILE__).'/1x1.png' );
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php
@@ -219,9 +219,6 @@
220220 // Other messages
221221 'centralauth-invalid-wiki' => 'No such wiki database: $1',
222222 'centralauth-account-exists' => 'Cannot create account: the requested username is already taken in the unified login system.',
223 - 'centralauth-autologin-desc' => 'This special page is used internally by MediaWiki.
224 -When you [[Special:UserLogin|log in]], the central login system instructs your browser to request this page from all linked domains, using image links.
225 -You have requested this page without providing any authentication data, so it does nothing.',
226223 'centralauth-login-progress' => 'Logging you in to Wikimedia\'s other projects:',
227224 'centralauth-logout-progress' => 'Logging you out from Wikimedia\'s other projects:',
228225
@@ -249,6 +246,12 @@
250247 'centralauth-rightslog-set-optin' => 'opt-in based',
251248 'centralauth-rightslog-set-optout' => 'opt-out based',
252249
 250+ // Autologin
 251+ 'autologin' => 'Automatic login',
 252+ 'centralauth-autologin-desc' => 'This special page is used internally by MediaWiki.
 253+When you [[Special:UserLogin|log in]], the central login system instructs your browser to request this page from all linked domains, using image links.
 254+You have requested this page without providing any authentication data, so it does nothing.',
 255+
253256 // Global group membership
254257 'globalgroupmembership' => 'Membership in global groups',
255258