Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/84998
Change subject: Don't fail autologin for unattached accounts
......................................................................
Don't fail autologin for unattached accounts
For the post-login icons, we don't want to fail logging in to e.g. all
language wiktionaries if the user happens to not have an account on
en.wiktionary or the en.wiktionary account exists but isn't attached. So
don't require an attached account for the icon auto-logins.
But the script autologin is a different matter. In that case we *do*
want the local account to exist and be attached (that was bug 51603), so
if we get to that code path make it so.
Bug: 54292
Change-Id: I0ca1a33500784a30e9f04d1d1a5dd13901084441
---
M specials/SpecialCentralAutoLogin.php
1 file changed, 18 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth
refs/changes/98/84998/1
diff --git a/specials/SpecialCentralAutoLogin.php
b/specials/SpecialCentralAutoLogin.php
index e31fec6..cf7dc66 100644
--- a/specials/SpecialCentralAutoLogin.php
+++ b/specials/SpecialCentralAutoLogin.php
@@ -271,16 +271,14 @@
return;
}
- // Load and check CentralAuthUser
+ // Load and check CentralAuthUser. But don't check if
it's
+ // attached, because then if the user is missing
en.site they
+ // won't be auto logged in to any of the non-en
versions either.
$centralUser = new CentralAuthUser(
$memcData['userName'] );
if ( !$centralUser->getId() || $centralUser->getId() !=
$memcData['gu_id'] ) {
$msg = "Wrong user: expected
{$memcData['gu_id']}, got {$centralUser->getId()}";
wfDebug( __METHOD__ . ": $msg\n" );
$this->doFinalOutput( false, 'Lost session' );
- return;
- }
- if ( !$centralUser->isAttached() ) {
- $this->doFinalOutput( false, 'Local user is not
attached', $notLoggedInScript );
return;
}
$loginResult = $centralUser->authenticateWithToken(
$memcData['token'] );
@@ -317,6 +315,21 @@
return;
}
+ // If it is a script callback, then we do want to
create the user
+ // if it doesn't already exist locally (and fail if
that can't be
+ // done).
+ if ( !User::idFromName( $centralUser->getName() ) ) {
+ $user = new User;
+ $user->setName( $userName );
+ if ( CentralAuthHooks::attemptAddUser( $user )
) {
+ $centralUser->invalidateCache();
+ }
+ }
+ if ( !$centralUser->isAttached() ) {
+ $this->doFinalOutput( false, 'Local user is not
attached', $notLoggedInScript );
+ return;
+ }
+
$script = "if ( 'localStorage' in window ) {" .
"localStorage.removeItem( 'CentralAuthAnon' );"
.
"}" .
--
To view, visit https://gerrit.wikimedia.org/r/84998
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ca1a33500784a30e9f04d1d1a5dd13901084441
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits