Make 40621 not break CentralAuth
authorAryeh Gregor <simetrical@users.mediawiki.org>
Mon, 8 Sep 2008 22:15:44 +0000 (22:15 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Mon, 8 Sep 2008 22:15:44 +0000 (22:15 +0000)
If $injected_html is provided, then the redirect page on login will still be shown.  This is needed for auto-login in CentralAuth.  I can't test that the fix works, though, because I don't have CentralAuth installed.  Unfortunately, this means Wikipedia won't benefit from one less click, but I can't think of an easy way around that.

docs/hooks.txt
includes/specials/SpecialUserlogin.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 7e2814a..9e9dbf9 100644 (file)
@@ -1357,9 +1357,7 @@ $user: user object being loaded
 
 'UserLoginComplete': after a user has logged in
 $user: the user object that was created on login
-$inject_html: Any HTML to inject after the "logged in" message.  As of 1.14,
-  this only applies to new account creations, since simple logins are HTTP re-
-  directs.
+$inject_html: Any HTML to inject after the "logged in" message.
                    
 'UserLoginForm': change to manipulate the login form
 $template: SimpleTemplate instance for the form
index c4481c4..53b1aa5 100644 (file)
@@ -681,16 +681,20 @@ class LoginForm {
        function successfulLogin() {
                global $wgUser, $wgOut;
 
-               # Run any hooks; ignore injected HTML since we just redirect
+               # Run any hooks; display injected HTML if any, else redirect
                $injected_html = '';
                wfRunHooks('UserLoginComplete', array(&$wgUser, &$injected_html));
 
-               $titleObj = Title::newFromText( $this->mReturnTo );
-               if ( !$titleObj instanceof Title ) {
-                       $titleObj = Title::newMainPage();
-               }
+               if( $injected_html !== '' ) {
+                       $this->displaySuccessfulLogin( 'loginsuccess', $injected_html );
+               } else {
+                       $titleObj = Title::newFromText( $this->mReturnTo );
+                       if ( !$titleObj instanceof Title ) {
+                               $titleObj = Title::newMainPage();
+                       }
 
-               $wgOut->redirect( $titleObj->getFullURL() );
+                       $wgOut->redirect( $titleObj->getFullURL() );
+               }
        }
 
        /**
@@ -706,10 +710,19 @@ class LoginForm {
                $injected_html = '';
                wfRunHooks('UserLoginComplete', array(&$wgUser, &$injected_html));
 
+               $this->displaySuccessfulLogin( 'welcomecreation', $injected_html );
+       }
+
+       /**
+        * Display a "login successful" page.
+        */
+       private function displaySuccessfulLogin( $msgname, $injected_html ) {
+               global $wgOut;
+
                $wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) );
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
                $wgOut->setArticleRelated( false );
-               $wgOut->addWikiMsg( 'welcomecreation', $wgUser->getName() );
+               $wgOut->addWikiMsg( $msgname, $wgUser->getName() );
                $wgOut->addHtml( $injected_html );
 
                if ( !empty( $this->mReturnTo ) ) {
index d8d6ad3..11204d8 100644 (file)
@@ -928,6 +928,7 @@ You have cookies disabled.
 Please enable them and try again.',
 'noname'                     => 'You have not specified a valid user name.',
 'loginsuccesstitle'          => 'Login successful',
+'loginsuccess'               => "'''You are now logged in to {{SITENAME}} as \"\$1\".'''",
 'nosuchuser'                 => 'There is no user by the name "$1".
 Check your spelling, or create a new account.',
 'nosuchusershort'            => 'There is no user by the name "<nowiki>$1</nowiki>".
index be0be0f..236bfc6 100644 (file)
@@ -405,6 +405,7 @@ $wgMessageStructure = array(
                'nocookieslogin',
                'noname',
                'loginsuccesstitle',
+               'loginsuccess',
                'nosuchuser',
                'nosuchusershort',
                'nouserspecified',