- $abortError = '';
- if( !wfRunHooks( 'AbortNewAccount', array( $user->getName(), &$abortError ) ) ) {
- // Hook point to add extra creation throttles and blocks
- wfDebug( __METHOD__.": a hook blocked creation\n" );
- $this->mainLoginForm( $abortError );
- return self::ABORTED;
+ /**
+ * If the external authentication plugin allows it, automatically cre-
+ * ate a new account for users that are externally defined but have not
+ * yet logged in.
+ */
+ if ( $this->mExtUser ) {
+ # mExtUser is neither null nor false, so use the new ExternalAuth
+ # system.
+ if ( $wgAutocreatePolicy == 'never' ) {
+ return self::NOT_EXISTS;
+ }
+ if ( !$this->mExtUser->authenticate( $this->mPassword ) ) {
+ return self::WRONG_PLUGIN_PASS;
+ }
+ } else {
+ # Old AuthPlugin.
+ if ( !$wgAuth->autoCreate() ) {
+ return self::NOT_EXISTS;
+ }
+ if ( !$wgAuth->userExists( $user->getName() ) ) {
+ wfDebug( __METHOD__.": user does not exist\n" );
+ return self::NOT_EXISTS;
+ }
+ if ( !$wgAuth->authenticate( $user->getName(), $this->mPassword ) ) {
+ wfDebug( __METHOD__.": \$wgAuth->authenticate() returned false, aborting\n" );
+ return self::WRONG_PLUGIN_PASS;
+ }