MarkAHershberger has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/369585 )
Change subject: Add earlier hook to avoid JS redirect
......................................................................
Add earlier hook to avoid JS redirect
Note that we have to pass in $title by ref because we will replace the object.
Change-Id: I3eff5988c95738ef6de5fd8404ad3becba09b0c8
---
M PluggableAuthHooks.php
1 file changed, 42 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PluggableAuth
refs/changes/85/369585/1
diff --git a/PluggableAuthHooks.php b/PluggableAuthHooks.php
index a82d024..724faec 100644
--- a/PluggableAuthHooks.php
+++ b/PluggableAuthHooks.php
@@ -176,4 +176,46 @@
unset( $personal_urls['logout'] );
}
}
+
+ /**
+ * Implements PersonalUrls hook.
+ * See https://www.mediawiki.org/wiki/Manual:Hooks/BeforeInitialize
+ * Redirects ASAP to login
+ * @param Title &$title being used for request
+ * @param Article $article associated Article
+ * @param OutputPage $out object
+ * @param User $user current user
+ * @param WebRequest $request why we're here
+ * @param MediaWiki $mw object
+ *
+ * Note that $title has to be passed by ref so we can replace it.
+ */
+ public static function doBeforeInitialize(
+ Title &$title, Article $article, OutputPage $out, User $user,
+ WebRequest $request, MediaWiki $mw
+ ) {
+ if ( !$GLOBALS['wgPluggableAuth_EnableAutoLogin'] ) {
+ return;
+ }
+ if ( !$out->getUser()->isAnon() ) {
+ return;
+ }
+ if ( !User::isEveryoneAllowed( 'read' ) && $title->userCan(
'read' ) ) {
+ return;
+ }
+ $loginSpecialPages =
ExtensionRegistry::getInstance()->getAttribute(
+ 'PluggableAuthLoginSpecialPages' );
+ foreach ( $loginSpecialPages as $page ) {
+ if ( $title->isSpecial( $page ) ) {
+ return;
+ }
+ }
+
+ $oldTitle = $title;
+ $title = Title::newFromText( "UserLogin", NS_SPECIAL );
+ $out->redirect( $title->getFullURL( [
+ 'returnto' => $oldTitle,
+ 'returntoquery' => $request->getRawQueryString()
+ ] ) );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/369585
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3eff5988c95738ef6de5fd8404ad3becba09b0c8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PluggableAuth
Gerrit-Branch: master
Gerrit-Owner: MarkAHershberger <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits