mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SpamBlacklist
synced 2024-11-23 22:54:57 +00:00
Update for AuthManager
Needs I8b52ec8ddf494f23941807638f149f15b5e46b0c to do anything useful. Bug: T110467 Change-Id: Ifb6fea581a0d0ae8db46e82b6fa6d25239cf3d8e
This commit is contained in:
parent
83b178eee6
commit
303ba31639
|
@ -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' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
15
SpamBlacklistPreAuthenticationProvider.php
Normal file
15
SpamBlacklistPreAuthenticationProvider.php
Normal 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' );
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue