From 141cacce63b79ccca47dad8616b4aeed9698cba3 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Mon, 8 Sep 2008 22:15:44 +0000 Subject: [PATCH] Make 40621 not break CentralAuth 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 | 4 +--- includes/specials/SpecialUserlogin.php | 27 +++++++++++++++++++------- languages/messages/MessagesEn.php | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 7e2814ab54..9e9dbf9ee7 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index c4481c4474..53b1aa5cf6 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -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 ) ) { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index d8d6ad3268..11204d8063 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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 "$1". diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index be0be0f5f8..236bfc651e 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -405,6 +405,7 @@ $wgMessageStructure = array( 'nocookieslogin', 'noname', 'loginsuccesstitle', + 'loginsuccess', 'nosuchuser', 'nosuchusershort', 'nouserspecified', -- 2.20.1