Add new hook, AbortNewAccountAuto, to abort account creations from AuthPlugin- or...
authorHappy-melon <happy-melon@users.mediawiki.org>
Thu, 24 Sep 2009 12:50:12 +0000 (12:50 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Thu, 24 Sep 2009 12:50:12 +0000 (12:50 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/Login.php

index 644dc3d..c445e05 100644 (file)
@@ -92,6 +92,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   $template->set(), etc.  The hook has access to most of the stuff that will go into the
   Login/Create form; see the documentation on HTMLForm for syntax for extra fields.
   LoginForm class is deprecated, its state constants are now in the Login class.
+* New hook AbortNewAccountAuto, called before account creation from AuthPlugin-
+  or ExtUser-driven requests.
 
 === New features in 1.16 ===
 
index 325a062..4bfa457 100644 (file)
@@ -259,6 +259,12 @@ $reason: the reason for the move (added in 1.13)
 $user: the User object about to be created (read-only, incomplete)
 $message: out parameter: error message to display on abort
 
+'AbortNewAccountAuto': Return false to cancel account creation when the
+    request is coming from an AuthPlugin or ExtUser, rather than a 
+    manually-submitted CreateAccount form.
+$user: the User object about to be created (read-only, incomplete)
+$message: out parameter: error message to display on abort
+
 'AddNewAccount': after a user account is created
 $user: the User object that was created. (Parameter added in 1.7)
 $byEmail: true when account was created "by email" (added in 1.12)
index d13c574..42a0e76 100644 (file)
@@ -232,12 +232,20 @@ class Login {
                # is for an external auth plugin to autocreate the local user first.
                if ( $this->mUser->getID() == 0 ) {
                        if ( $this->canAutoCreate() == self::SUCCESS ) {
+                               
                                $isAutoCreated = true;
                                wfDebug( __METHOD__.": creating account\n" );
+                               
+                               if( !wfRunHooks( 'AbortNewAccountAuto', array( $this->mUser, &$this->mCreateResult ) ) ) {
+                                       wfDebug( __METHOD__ . ": a hook blocked creation\n" );
+                                       return self::ABORTED;
+                               }
+                               
                                $result = $this->initUser( true );
                                if( $result !== self::SUCCESS ){
                                        return $result;
-                               };
+                               }
+                               
                        } else {
                                return $this->canAutoCreate();
                        }
@@ -454,7 +462,7 @@ class Login {
 
                if( !wfRunHooks( 'AbortNewAccount', array( $this->mUser, &$this->mCreateResult ) ) ) {
                        # Hook point to add extra creation throttles and blocks
-                       wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" );
+                       wfDebug( __METHOD__ . ": a hook blocked creation\n" );
                        return self::ABORTED;
                }