jenkins-bot has submitted this change and it was merged.
Change subject: Interstitial notification page for renamed users
......................................................................
Interstitial notification page for renamed users
Redirect users who have been authenticated to a renamed central account
using their previous local username to an interstital page telling them
to login using the new name in the future and giving other helpful
advice about the SUL rename process.
Bug: 67995
Change-Id: I7bf1dd18d578b52e29e2f29933fcbd9b3261ae99
---
M CentralAuth.alias.php
M i18n/en.json
M i18n/qqq.json
M includes/CentralAuthHooks.php
A includes/specials/SpecialSulRenameWarning.php
5 files changed, 128 insertions(+), 6 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/CentralAuth.alias.php b/CentralAuth.alias.php
index 5d67def..c5af979 100644
--- a/CentralAuth.alias.php
+++ b/CentralAuth.alias.php
@@ -24,6 +24,7 @@
'GlobalUserMerge' => array( 'GlobalUserMerge' ),
'GlobalRenameRequest' => array( 'GlobalRenameRequest' ),
'GlobalRenameQueue' => array( 'GlobalRenameQueue' ),
+ 'SulRenameWarning' => array( 'SulRenameWarning' ),
);
/** Afrikaans (Afrikaans) */
diff --git a/i18n/en.json b/i18n/en.json
index c16b831..d84cadc 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -431,7 +431,6 @@
"centralauth-usermerge-form-adduser": "Add user",
"centralauth-usermerge-form-deleteuser": "Remove user",
"globalrenamerequest-status-text": "Your username change request is
currently in progress and awaiting approval by a steward. You will be notified
by email when the request is processed.\n\n;Current username:\n:$1\n;Requested
username:\n:$2",
- "centralauth-abortlogin-renamed": "Your account was renamed to \"$1\".
Please use that username instead.",
"globalrenamequeue": "Global rename request queue",
"globalrenamequeue-desc": "Process global rename requests",
"globalrenamequeue-nav-openqueue": "Open requests",
@@ -468,5 +467,9 @@
"globalrenamequeue-email-subject-approved": "Account rename request
approved",
"globalrenamequeue-email-subject-rejected": "Account rename request
rejected",
"globalrenamequeue-email-body-approved": "The request to rename \"$1\"
to \"$2\" has been approved.\n\n",
- "globalrenamequeue-email-body-rejected": "The request to rename \"$1\"
to \"$2\" has been rejected.\n\nNote: $3\n\n"
+ "globalrenamequeue-email-body-rejected": "The request to rename \"$1\"
to \"$2\" has been rejected.\n\nNote: $3\n\n",
+ "centralauth-abortlogin-renamed": "Your account was renamed to \"$1\".
Please use that username instead.",
+ "sulrenamewarning-title" : "{{GENDER:$1|Your}} account has been
renamed",
+ "sulrenamewarning-renamed" : "{{GENDER:$2|Your}} account '''$1''' has
been renamed to '''$2''' during automatic migration to the unified login system
of {{int:Centralauth-groupname}}.",
+ "sulrenamewarning-usenew" : "Please use {{GENDER:$1|your}} new username
'''$1''' when logging in in the future."
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 420961b..59e50f2 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -438,7 +438,6 @@
"globalrenamerequest-save-error": "Used as error message.",
"globalrenamerequest-status-title": "Page title when request is
pending.",
"globalrenamerequest-status-text": "Pending request description.\n\n*
$1 is the user's current name\n* $2 is the user's requested name",
- "centralauth-abortlogin-renamed": "Error message shown when the user's
account was renamed, and they need to login with their new
name.\n\nParameters:\n* $1 - the new username they should use",
"centralauth-usermerge-form-adduser": "Label on button that when
clicked adds a new form field to input a username into.\n{{Identical|Add
user}}",
"centralauth-usermerge-form-deleteuser": "Label on button that when
clicked removes the associated form field.\n{{Identical|Remove user}}",
"globalrenamequeue": "{{doc-special|GlobalRenameQueue}}",
@@ -475,5 +474,9 @@
"globalrenamequeue-email-subject-approved": "Email subject line for
approved request.",
"globalrenamequeue-email-subject-rejected": "Email subject line for
rejected request.",
"globalrenamequeue-email-body-approved": "Email body for approved
request.\n\n* $1 is the old username\n* $2 is the new username.",
- "globalrenamequeue-email-body-rejected": "Email body for rejected
request.\n\n* $1 is the old username.\n* $2 is the new username.\n* $3 is the
message left by the user who processed the request."
+ "globalrenamequeue-email-body-rejected": "Email body for rejected
request.\n\n* $1 is the old username.\n* $2 is the new username.\n* $3 is the
message left by the user who processed the request.",
+ "centralauth-abortlogin-renamed": "Error message shown when the user's
account was renamed, and they need to login with their new name\n\n* $1 is the
new username they should use.",
+ "sulrenamewarning-title" : "[[Special:SulRenameWarning]] title\n\n* $1
is the user's new name for GENDER",
+ "sulrenamewarning-renamed" : "Notice to user that their account has
been renamed.\n\n* $1 is the user's old name\n* $2 is the user's new name",
+ "sulrenamewarning-usenew" : "Instructions to user to login with new
name in the future\n\n* $1 is the user's new name"
}
diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php
index b5fa866..3096872 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -1,7 +1,6 @@
<?php
class CentralAuthHooks {
-
/**
* Callback to register with $wgExtensionFunctions to complete
configuration
* after other initial configuration has completed. This can be used to
@@ -13,7 +12,6 @@
global $wgSpecialPages, $wgSpecialPageGroups,
$wgResourceModules;
global $wgCentralAuthEnableGlobalRenameRequest;
global $wgCentralAuthCheckSULMigration;
-
$caBase = __DIR__ . '/..';
if ( class_exists( 'RenameuserSQL' ) ) {
@@ -94,6 +92,14 @@
'localBasePath' => "{$caBase}/modules",
'remoteExtPath' => 'CentralAuth/modules',
);
+ }
+
+ if ( $wgCentralAuthCheckSULMigration ) {
+ // Install hidden special page for renamed users
+ $wgAutoloadClasses['SpecialSulRenameWarning'] =
+
"$caBase/includes/specials/SpecialSulRenameWarning.php";
+ $wgSpecialPages['SulRenameWarning'] =
'SpecialSulRenameWarning';
+ $wgHooks['PostLoginRedirect'][] =
'CentralAuthHooks::onPostLoginRedirect';
}
if ( $wgCentralAuthCheckSULMigration ) {
@@ -1905,4 +1911,32 @@
);
return true;
}
+
+ /**
+ * Handler for PostLoginRedirect
+ * @param string $returnTo The page to return to
+ * @param array $returnToQuery Url parameters
+ * @param string $type Type of login redirect
+ */
+ public static function onPostLoginRedirect(
+ &$returnTo, &$returnToQuery, &$type
+ ) {
+ global $wgCentralAuthCheckSULMigration, $wgUser;
+ if ( $wgCentralAuthCheckSULMigration &&
+ $wgUser->getRequest()->getSessionData(
'CentralAuthForcedRename' ) === true &&
+ ( $type == 'success' || $type == 'successredirect' )
+ ) {
+ wfDebugLog( 'SUL', 'Redirecting user to
Special:SulRenameWarning' );
+ // Store current redirect target in session so we can
provide a link
+ // later.
+ $wgUser->getRequest()->setSessionData(
'SulRenameWarning', array(
+ 'returnTo' => $returnTo,
+ 'returnToQuery' => $returnToQuery,
+ ) );
+ $returnTo = SpecialPageFactory::getLocalNameFor(
'Special:SulRenameWarning' );
+ $returnToQuery = array();
+ return false;
+ }
+ return true;
+ }
}
diff --git a/includes/specials/SpecialSulRenameWarning.php
b/includes/specials/SpecialSulRenameWarning.php
new file mode 100644
index 0000000..dd88a59
--- /dev/null
+++ b/includes/specials/SpecialSulRenameWarning.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+/**
+ * Display a warning and instructions to a user who has logged in with
+ * a username that was affected by single user login (SUL) finalization.
+ *
+ * @author Bryan Davis <[email protected]>
+ * @copyright © 2014 Bryan Davis and Wikimedia Foundation.
+ */
+class SpecialSulRenameWarning extends UnlistedSpecialPage {
+ /**
+ * Constructor.
+ */
+ function __construct() {
+ parent::__construct( 'SulRenameWarning' );
+ }
+
+ /**
+ * Checks if the given user (identified by an object) can execute this
+ * special page (as defined by $mRestriction).
+ *
+ * @param User $user The user to check
+ * @return bool Does the user have permission to view the page?
+ */
+ public function userCanExecute( User $user ) {
+ // Only allow users who have been force renamed
+ return $user->getRequest()->getSessionData(
'CentralAuthForcedRename' ) === true;
+ }
+
+ /**
+ * Execute the page.
+ *
+ * @param string $subPage Ignored
+ */
+ public function execute( $subPage ) {
+ $this->setHeaders();
+ $this->checkPermissions();
+ $this->outputHeader();
+
+ $username = $this->getUser()->getName();
+ list( $oldname ) = explode( '~', $username, 2 );
+
+ $output = $this->getOutput();
+ $output->setPageTitle( $this->msg( 'sulrenamewarning-title',
$username ) );
+ $output->addWikiMsg( 'sulrenamewarning-renamed', $oldname,
$username );
+ $output->addWikiMsg( 'sulrenamewarning-usenew', $username );
+
+ $request = $this->getUser()->getRequest();
+ $prior = $request->getSessionData( 'SulRenameWarning' );
+ if ( $prior ) {
+ // Create a return to link for their original
destination
+ $returnToTitle = Title::newFromText( $prior['returnTo']
);
+ if ( !$returnToTitle ) {
+ $returnToTitle = Title::newMainPage();
+ }
+ $output->addReturnTo( $returnToTitle,
$prior['returnToQuery'] );
+
+ // Clear stored data from session
+ $request->setSessionData( 'SulRenameWarning', null );
+ }
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/148420
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7bf1dd18d578b52e29e2f29933fcbd9b3261ae99
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Deskana <[email protected]>
Gerrit-Reviewer: Jorm <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits