r56874 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56873‎ | r56874 | r56875 >
Date:12:50, 24 September 2009
Author:happy-melon
Status:ok
Tags:
Comment:
Add new hook, AbortNewAccountAuto, to abort account creations from AuthPlugin- or ExtUser-driven requests.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/Login.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -259,6 +259,12 @@
260260 $user: the User object about to be created (read-only, incomplete)
261261 $message: out parameter: error message to display on abort
262262
 263+'AbortNewAccountAuto': Return false to cancel account creation when the
 264+ request is coming from an AuthPlugin or ExtUser, rather than a
 265+ manually-submitted CreateAccount form.
 266+$user: the User object about to be created (read-only, incomplete)
 267+$message: out parameter: error message to display on abort
 268+
263269 'AddNewAccount': after a user account is created
264270 $user: the User object that was created. (Parameter added in 1.7)
265271 $byEmail: true when account was created "by email" (added in 1.12)
Index: trunk/phase3/includes/Login.php
@@ -232,12 +232,20 @@
233233 # is for an external auth plugin to autocreate the local user first.
234234 if ( $this->mUser->getID() == 0 ) {
235235 if ( $this->canAutoCreate() == self::SUCCESS ) {
 236+
236237 $isAutoCreated = true;
237238 wfDebug( __METHOD__.": creating account\n" );
 239+
 240+ if( !wfRunHooks( 'AbortNewAccountAuto', array( $this->mUser, &$this->mCreateResult ) ) ) {
 241+ wfDebug( __METHOD__ . ": a hook blocked creation\n" );
 242+ return self::ABORTED;
 243+ }
 244+
238245 $result = $this->initUser( true );
239246 if( $result !== self::SUCCESS ){
240247 return $result;
241 - };
 248+ }
 249+
242250 } else {
243251 return $this->canAutoCreate();
244252 }
@@ -454,7 +462,7 @@
455463
456464 if( !wfRunHooks( 'AbortNewAccount', array( $this->mUser, &$this->mCreateResult ) ) ) {
457465 # Hook point to add extra creation throttles and blocks
458 - wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" );
 466+ wfDebug( __METHOD__ . ": a hook blocked creation\n" );
459467 return self::ABORTED;
460468 }
461469
Index: trunk/phase3/RELEASE-NOTES
@@ -92,6 +92,8 @@
9393 $template->set(), etc. The hook has access to most of the stuff that will go into the
9494 Login/Create form; see the documentation on HTMLForm for syntax for extra fields.
9595 LoginForm class is deprecated, its state constants are now in the Login class.
 96+* New hook AbortNewAccountAuto, called before account creation from AuthPlugin-
 97+ or ExtUser-driven requests.
9698
9799 === New features in 1.16 ===
98100

Status & tagging log