FunPika has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/276075

Change subject: Use AntiSpoofAddConflicts hook
......................................................................

Use AntiSpoofAddConflicts hook

This uses a hook (added in Gerrit change 276061) to add global conflicts to
the output of SpoofUser:getConflicts, instead of running a copy of AntiSpoof's
AbortNewAccount hook code. This will allow other functions of AntiSpoof such as
the API module to detect global conflicts.

Bug: T126174
Change-Id: Idc0fe4b5de4c88b5a393d3cf20f821040514a422
Depends-On: I5372be6aa1160f390ae5c50c841f41b8a597915e
---
M AntiSpoof/CentralAuthAntiSpoofHooks.php
M includes/CentralAuthHooks.php
2 files changed, 5 insertions(+), 51 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/75/276075/1

diff --git a/AntiSpoof/CentralAuthAntiSpoofHooks.php 
b/AntiSpoof/CentralAuthAntiSpoofHooks.php
index d4fa369..29876f3 100644
--- a/AntiSpoof/CentralAuthAntiSpoofHooks.php
+++ b/AntiSpoof/CentralAuthAntiSpoofHooks.php
@@ -2,56 +2,10 @@
 
 class CentralAuthAntiSpoofHooks {
 
-       /**
-        * Can be used to cancel user account creation
-        *
-        * @param $user User
-        * @param $message string
-        * @return bool true to continue, false to abort user creation
-        */
-       public static function asAbortNewAccountHook( $user, &$message ) {
-               global $wgAntiSpoofAccounts, $wgUser, $wgRequest;
-
-               if ( !$wgAntiSpoofAccounts ) {
-                       $mode = 'LOGGING ';
-                       $active = false;
-               } elseif ( $wgRequest->getCheck( 'wpIgnoreAntiSpoof' ) &&
-                               $wgUser->isAllowed( 'override-antispoof' ) ) {
-                       $mode = 'OVERRIDE ';
-                       $active = false;
-               } else {
-                       $mode = '';
-                       $active = true;
-               }
-
-               $name = $user->getName();
+       public static function asAntiSpoofAddConflicts( &$spoofs, $name ) {
                $spoof = new CentralAuthSpoofUser( $name );
-               if ( $spoof->isLegal() ) {
-                       $normalized = $spoof->getNormalized();
-                       $conflicts = $spoof->getConflicts();
-                       if ( empty( $conflicts ) ) {
-                               wfDebugLog( 'antispoof', "{$mode}PASS new 
account '$name' [$normalized]" );
-                       } else {
-                               wfDebugLog( 'antispoof', "{$mode}CONFLICT new 
account '$name' [$normalized] spoofs " . implode( ',', $conflicts ) );
-                               if ( $active ) {
-                                       $numConflicts = count( $conflicts );
-                                       $message = wfMessage( 
'antispoof-conflict-top', $name )->numParams( $numConflicts )->escaped();
-                                       $message .= '<ul>';
-                                       foreach ( $conflicts as $simUser ) {
-                                               $message .= '<li>' . wfMessage( 
'antispoof-conflict-item', $simUser )->escaped() . '</li>';
-                                       }
-                                       $message .= '</ul>' . wfMessage( 
'antispoof-conflict-bottom' )->escaped();
-                                       return false;
-                               }
-                       }
-               } else {
-                       $error = $spoof->getError();
-                       wfDebugLog( 'antispoof', "{$mode}ILLEGAL new account 
'$name' $error" );
-                       if ( $active ) {
-                               $message = wfMessage( 'antispoof-name-illegal', 
$name, $error )->escaped();
-                               return false;
-                       }
-               }
+               $spoof->spoofedUsers( &$spoofs );
+
                return true;
        }
 
diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php
index 6e8d9d0..4fc7259 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -42,8 +42,8 @@
                        $wgAutoloadClasses['CentralAuthAntiSpoofHooks'] =
                                
"$caBase/AntiSpoof/CentralAuthAntiSpoofHooks.php";
 
-                       $wgHooks['AbortNewAccount'][] =
-                               
'CentralAuthAntiSpoofHooks::asAbortNewAccountHook';
+                       $wgHooks['AntiSpoofAddConflicts'][] =
+                               
'CentralAuthAntiSpoofHooks::asAntiSpoofAddConflicts';
                        $wgHooks['AddNewAccount'][] =
                                
'CentralAuthAntiSpoofHooks::asAddNewAccountHook';
                        $wgHooks['RenameUserComplete'][] =

-- 
To view, visit https://gerrit.wikimedia.org/r/276075
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc0fe4b5de4c88b5a393d3cf20f821040514a422
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: FunPika <funpikaw...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to