From: Rob Church Date: Sun, 30 Apr 2006 01:59:56 +0000 (+0000) Subject: (bug 5377) Do not auto-login when creating an account as another user X-Git-Tag: 1.31.0-rc.0~57317 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=c25c53f443f2ee7d9c9df321a96d674bfa541764;p=lhc%2Fweb%2Fwiklou.git (bug 5377) Do not auto-login when creating an account as another user --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ee66cde0a3..8bb3d64c4e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -151,7 +151,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 5764) Friulian translation updated * (bug 5757) Fix premature cutoff in LanguageConverter with extra end markers * (bug 5516) Show appropriate "return to" link on blocked page - +* (bug 5377) Do not auto-login when creating an account as another user == Compatibility == diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index caedffbcad..1fdf9752ae 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -135,27 +135,41 @@ class LoginForm { */ function addNewAccount() { global $wgUser, $wgEmailAuthentication; - + + # Create the account and abort if there's a problem doing so $u = $this->addNewAccountInternal(); - - if ($u == NULL) { + if( $u == NULL ) return; - } - - $wgUser = $u; - $wgUser->setCookies(); - - $wgUser->saveSettings(); - if( $wgEmailAuthentication && $wgUser->isValidEmailAddr( $wgUser->getEmail() ) ) { - $wgUser->sendConfirmationMail(); - } - + + # Save user settings and send out an email authentication message if needed + $u->saveSettings(); + if( $wgEmailAuthentication && User::isValidEmailAddr( $u->getEmail() ) ) + $u->sendConfirmationMail(); + + # Call hooks wfRunHooks( 'AddNewAccount', array( $u ) ); - - if( $this->hasSessionCookie() ) { - return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false ); + + # If not logged in, assume the new account as the current one and set session cookies + # then show a "welcome" message or a "need cookies" message as needed + if( $wgUser->isAnon() ) { + $wgUser = $u; + $wgUser->setCookies(); + if( $this->hasSessionCookie() ) { + return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false ); + } else { + return $this->cookieRedirectCheck( 'new' ); + } } else { - return $this->cookieRedirectCheck( 'new' ); + # Confirm that the account was created + global $wgOut; + $skin = $wgUser->getSkin(); + $self = Title::makeTitle( NS_SPECIAL, 'Userlogin' ); + $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) ); + $wgOut->setArticleRelated( false ); + $wgOut->setRobotPolicy( 'noindex,nofollow' ); + $wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) ); + $wgOut->returnToMain( $self->getPrefixedText() ); + return true; } } diff --git a/languages/Messages.php b/languages/Messages.php index bb5dca40b7..40307eb86b 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -432,6 +432,8 @@ will be sent for any of the following features.', 'emailconfirmlink' => 'Confirm your e-mail address', 'invalidemailaddress' => 'The e-mail address cannot be accepted as it appears to have an invalid format. Please enter a well-formatted address or empty that field.', +'accountcreated' => 'Account created', +'accountcreatedtext' => 'The user account for $1 has been created.', # Edit page toolbar 'bold_sample'=>'Bold text',