Update for AuthManager

Needs I8b52ec8ddf494f23941807638f149f15b5e46b0c to
do anything useful.

Bug: T110467
Change-Id: Ifb6fea581a0d0ae8db46e82b6fa6d25239cf3d8e
This commit is contained in:
Gergő Tisza 2016-05-08 08:17:29 +00:00
parent 83b178eee6
commit 303ba31639
3 changed files with 27 additions and 4 deletions

View file

@ -1,5 +1,7 @@
<?php
use MediaWiki\Auth\AuthManager;
/**
* Hooks for the spam blacklist extension
*/
@ -10,6 +12,7 @@ class SpamBlacklistHooks {
*/
public static function registerExtension() {
global $wgSpamBlacklistFiles, $wgBlacklistSettings, $wgSpamBlacklistSettings;
global $wgDisableAuthManager, $wgAuthManagerAutoConfig;
$wgBlacklistSettings = array(
'spam' => 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' );
}
}
/**

View file

@ -0,0 +1,15 @@
<?php
use MediaWiki\Auth\AbstractPreAuthenticationProvider;
class SpamBlacklistPreAuthenticationProvider extends AbstractPreAuthenticationProvider {
public function testForAccountCreation( $user, $creator, array $reqs ) {
/** @var $blacklist EmailBlacklist */
$blacklist = BaseBlacklist::getInstance( 'email' );
if ( $blacklist->checkUser( $user ) ) {
return StatusValue::newGood();
}
return StatusValue::newFatal( 'spam-blacklisted-email-signup' );
}
}

View file

@ -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"
]