Index: trunk/extensions/CentralAuth/SpecialAutoLogin.php |
— | — | @@ -8,24 +8,24 @@ |
9 | 9 | * |
10 | 10 | * @addtogroup Extensions |
11 | 11 | */ |
12 | | - |
13 | | -class SpecialAutoLogin extends UnlistedSpecialPage |
14 | | -{ |
| 12 | +class SpecialAutoLogin extends UnlistedSpecialPage { |
| 13 | + |
15 | 14 | function __construct() { |
16 | 15 | parent::__construct('AutoLogin'); |
17 | 16 | } |
18 | | - |
| 17 | + |
19 | 18 | function execute( $par ) { |
20 | 19 | global $wgRequest, $wgOut, $wgUser, $wgMemc, $IP; |
21 | | - |
22 | | - $tempToken = $wgRequest->getVal('token'); |
| 20 | + |
| 21 | + $tempToken = $wgRequest->getVal( 'token' ); |
23 | 22 | $logout = $wgRequest->getBool( 'logout' ); |
24 | 23 | |
25 | 24 | # Don't cache error messages |
26 | 25 | $wgOut->enableClientCache( false ); |
27 | 26 | |
28 | | - if (strlen($tempToken) == 0) { |
| 27 | + if( strlen( $tempToken ) == 0 ) { |
29 | 28 | wfLoadExtensionMessages( 'SpecialCentralAuth' ); |
| 29 | + $this->setHeaders(); |
30 | 30 | $wgOut->addWikiMsg( 'centralauth-autologin-desc' ); |
31 | 31 | return; |
32 | 32 | } |
— | — | @@ -34,9 +34,11 @@ |
35 | 35 | $data = $wgMemc->get( $key ); |
36 | 36 | $wgMemc->delete( $key ); |
37 | 37 | |
38 | | - if ( !$data ) { |
| 38 | + if( !$data ) { |
39 | 39 | $msg = 'Token is invalid or has expired'; |
40 | 40 | wfDebug( __METHOD__.": $msg\n" ); |
| 41 | + wfLoadExtensionMessages( 'SpecialCentralAuth' ); |
| 42 | + $this->setHeaders(); |
41 | 43 | $wgOut->addWikiText( $msg ); |
42 | 44 | return; |
43 | 45 | } |
— | — | @@ -44,22 +46,24 @@ |
45 | 47 | $userName = $data['userName']; |
46 | 48 | $token = $data['token']; |
47 | 49 | $remember = $data['remember']; |
48 | | - |
49 | | - #die( print_r( $data, true )); |
50 | | - |
51 | | - if ($data['wiki'] != wfWikiID()) { |
| 50 | + |
| 51 | + if( $data['wiki'] != wfWikiID() ) { |
52 | 52 | $msg = 'Bad token (wrong wiki)'; |
53 | 53 | wfDebug( __METHOD__.": $msg\n" ); |
| 54 | + wfLoadExtensionMessages( 'SpecialCentralAuth' ); |
| 55 | + $this->setHeaders(); |
54 | 56 | $wgOut->addWikiText( $msg ); |
55 | 57 | return; |
56 | 58 | } |
57 | | - |
| 59 | + |
58 | 60 | $centralUser = new CentralAuthUser( $userName ); |
59 | 61 | $loginResult = $centralUser->authenticateWithToken( $token ); |
60 | | - |
61 | | - if ($loginResult != 'ok') { |
| 62 | + |
| 63 | + if( $loginResult != 'ok' ) { |
62 | 64 | $msg = "Bad token: $loginResult"; |
63 | 65 | wfDebug( __METHOD__.": $msg\n" ); |
| 66 | + wfLoadExtensionMessages( 'SpecialCentralAuth' ); |
| 67 | + $this->setHeaders(); |
64 | 68 | $wgOut->addWikiText( $msg ); |
65 | 69 | return; |
66 | 70 | } |
— | — | @@ -68,7 +72,7 @@ |
69 | 73 | if ( $logout ) { |
70 | 74 | $centralUser->deleteGlobalCookies(); |
71 | 75 | } else { |
72 | | - $centralUser->setGlobalCookies($remember); |
| 76 | + $centralUser->setGlobalCookies( $remember ); |
73 | 77 | } |
74 | 78 | |
75 | 79 | $wgOut->disable(); |
— | — | @@ -78,7 +82,7 @@ |
79 | 83 | header( 'Content-Type: image/png' ); |
80 | 84 | |
81 | 85 | global $wgCentralAuthLoginIcon; |
82 | | - if ( $wgCentralAuthLoginIcon ) { |
| 86 | + if( $wgCentralAuthLoginIcon ) { |
83 | 87 | readfile( $wgCentralAuthLoginIcon ); |
84 | 88 | } else { |
85 | 89 | readfile( dirname(__FILE__).'/1x1.png' ); |
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php |
— | — | @@ -219,9 +219,6 @@ |
220 | 220 | // Other messages |
221 | 221 | 'centralauth-invalid-wiki' => 'No such wiki database: $1', |
222 | 222 | '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.', |
226 | 223 | 'centralauth-login-progress' => 'Logging you in to Wikimedia\'s other projects:', |
227 | 224 | 'centralauth-logout-progress' => 'Logging you out from Wikimedia\'s other projects:', |
228 | 225 | |
— | — | @@ -249,6 +246,12 @@ |
250 | 247 | 'centralauth-rightslog-set-optin' => 'opt-in based', |
251 | 248 | 'centralauth-rightslog-set-optout' => 'opt-out based', |
252 | 249 | |
| 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 | + |
253 | 256 | // Global group membership |
254 | 257 | 'globalgroupmembership' => 'Membership in global groups', |
255 | 258 | |