From 303ba316398dc2563d1b01af1877fb751acf1058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Tisza?= Date: Sun, 8 May 2016 08:17:29 +0000 Subject: [PATCH] Update for AuthManager Needs I8b52ec8ddf494f23941807638f149f15b5e46b0c to do anything useful. Bug: T110467 Change-Id: Ifb6fea581a0d0ae8db46e82b6fa6d25239cf3d8e --- SpamBlacklistHooks.php | 10 ++++++++++ SpamBlacklistPreAuthenticationProvider.php | 15 +++++++++++++++ extension.json | 6 ++---- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 SpamBlacklistPreAuthenticationProvider.php diff --git a/SpamBlacklistHooks.php b/SpamBlacklistHooks.php index 051ff795..e7df36c1 100755 --- a/SpamBlacklistHooks.php +++ b/SpamBlacklistHooks.php @@ -1,5 +1,7 @@ array( @@ -26,6 +29,13 @@ class SpamBlacklistHooks { * @deprecated */ $wgSpamBlacklistSettings =& $wgBlacklistSettings['spam']; + + if ( class_exists( AuthManager::class ) && !$wgDisableAuthManager ) { + $wgAuthManagerAutoConfig['preauth'][SpamBlacklistPreAuthenticationProvider::class] = + [ 'class' => SpamBlacklistPreAuthenticationProvider::class ]; + } else { + Hooks::register( 'AbortNewAccount', 'SpamBlacklistHooks::abortNewAccount' ); + } } /** diff --git a/SpamBlacklistPreAuthenticationProvider.php b/SpamBlacklistPreAuthenticationProvider.php new file mode 100644 index 00000000..0880103b --- /dev/null +++ b/SpamBlacklistPreAuthenticationProvider.php @@ -0,0 +1,15 @@ +checkUser( $user ) ) { + return StatusValue::newGood(); + } + + return StatusValue::newFatal( 'spam-blacklisted-email-signup' ); + } +} diff --git a/extension.json b/extension.json index 56042942..10075119 100644 --- a/extension.json +++ b/extension.json @@ -44,7 +44,8 @@ "EmailBlacklist": "EmailBlacklist.php", "SpamBlacklistHooks": "SpamBlacklistHooks.php", "SpamBlacklist": "SpamBlacklist_body.php", - "SpamRegexBatch": "SpamRegexBatch.php" + "SpamRegexBatch": "SpamRegexBatch.php", + "SpamBlacklistPreAuthenticationProvider": "SpamBlacklistPreAuthenticationProvider.php" }, "Hooks": { "EditFilterMergedContent": [ @@ -62,9 +63,6 @@ "UserCanSendEmail": [ "SpamBlacklistHooks::userCanSendEmail" ], - "AbortNewAccount": [ - "SpamBlacklistHooks::abortNewAccount" - ], "ParserOutputStashForEdit": [ "SpamBlacklistHooks::onParserOutputStashForEdit" ]