Last modified: 2011-12-20 19:21:47 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T32671, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 30671 - CentralAuth should globally autologin user on account creation
CentralAuth should globally autologin user on account creation
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
CentralAuth (Other open bugs)
unspecified
All All
: High normal (vote)
: ---
Assigned To: Sam Reed (reedy)
: platformeng
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-01 01:06 UTC by Erik Moeller
Modified: 2011-12-20 19:21 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Erik Moeller 2011-09-01 01:06:07 UTC
Currently, when you first create an account, you don't get logged into non-WMF projects. You have to log out and log back in again to be logged in globally.

This is very non-intuitive behavior. One of the consequences is that, when a user first signs up and tries to upload a file, they hit a "You have to log in" warning on Commons -- even though they already have an account.

The user should be logged in globally immediately, i.e. the onUserLoginComplete hook probably should be run on successful account creation.
Comment 1 Erik Moeller 2011-09-01 01:08:27 UTC
s/non-WMF projects/WMF projects with another domain name/
Comment 2 Brion Vibber 2011-09-06 21:41:12 UTC
Hmm, this was always meant to work -- either it's a regression or nobody noticed for a few years. :)
Comment 3 Rob Lanphier 2011-09-23 00:06:47 UTC
Sam, could you take a look at this one?
Comment 4 Sam Reed (reedy) 2011-09-23 20:50:22 UTC
(In reply to comment #2)
> Hmm, this was always meant to work -- either it's a regression or nobody
> noticed for a few years. :)

Quick look at the code that is in the CentralAuthHooks::onUserLoginComplete hook...

		$inject_html .= '<div class="centralauth-login-box"><p>' .
			wfMsgExt( 'centralauth-login-progress', array( 'parsemag' ), $user->getName() ) . "</p>\n<p>";
		foreach ( $wgCentralAuthAutoLoginWikis as $alt => $wiki ) {
			$data = array(
				'userName' => $user->getName(),
				'token' => $centralUser->getAuthToken(),
				'remember' => $user->getOption( 'rememberpassword' ),
				'wiki' => $wiki
			);
			$loginToken = wfGenerateToken( $centralUser->getId() );
			global $wgMemc;
			$wgMemc->set( CentralAuthUser::memcKey( 'login-token', $loginToken ), $data, 600 );

			$wiki = WikiMap::getWiki( $wiki );
			$url = wfAppendQuery( $wiki->getUrl( 'Special:AutoLogin' ), "token=$loginToken" );

			$inject_html .= Xml::element( 'img',
				array(
					'src' => $url,
					'alt' => $alt,
					'title' => $alt,
					'width' => 20,
					'height' => 20,
					'style' => 'border: 1px solid #ccc;',
				)
			);
		}

		$inject_html .= '</p></div>';

Seemingly that needs refactoring out/duplicating to a subscriber to CentralAuthHooks::onAddNewAccount

But we don't have an as "nice" way of injecting the HTML back
Comment 5 Jeroen De Dauw 2011-11-11 13:37:46 UTC
I looked at this a bit, and although I'm not sure, I suspect the issue is this check:

if ( !$wgRequest->getCheck( 'wpCentralLogin' ) ) {
	// The user requested to log in just on this wiki
	return true;
}

Since the account creation page does not appear to have the wpCentralLogin checkbox. Changing it to something like this might fix the issue:

if ( !$wgRequest->getCheck( 'wpCentralLogin' ) && !$wgRequest->getCheck( 'wpCreateaccount' ) ) {
	// The user requested to log in just on this wiki
	return true;
}

Apart from that the code looks valid to me; if I'm not mistaken the onUserLoginComplete method should be getting called on account creation. To many hooks and undocumented stuff to be sure without testing, which I'm not set up for, though.
Comment 6 Sam Reed (reedy) 2011-12-20 13:36:27 UTC
(In reply to comment #5)
> Apart from that the code looks valid to me; if I'm not mistaken the
> onUserLoginComplete method should be getting called on account creation. To
> many hooks and undocumented stuff to be sure without testing, which I'm not set
> up for, though.

Yup, UserLoginComplete hook is fired on UserSignup. I'd guess that your suggested fix should work...
Comment 7 Sam Reed (reedy) 2011-12-20 14:41:57 UTC
This is indeed a regression, I'm guessing it broke around the time the "Also log me in to other wikis of the Wikimedia Foundation" checkbox was added in r75041, and the short circuit to exit was added...

Hopefully fixed per Jeroen in r106801

Need to poke and verify
Comment 8 Sam Reed (reedy) 2011-12-20 15:06:58 UTC
Yup, looks fine locally :)
Comment 9 Sam Reed (reedy) 2011-12-20 19:21:47 UTC
Brion reverted the whole checkbox out in r106839

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links