Index: trunk/extensions/SignupAPI/includes/SpecialUserSignup.php |
— | — | @@ -46,6 +46,7 @@ |
47 | 47 | const BLOCKED_BY_HOOK = 15; |
48 | 48 | const EXTR_DB_ERROR = 16; |
49 | 49 | const THROTLLED = 17; |
| 50 | + const INIT_FAILED = 18; |
50 | 51 | |
51 | 52 | |
52 | 53 | //Initialise all variables to be used |
— | — | @@ -55,7 +56,7 @@ |
56 | 57 | var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS; |
57 | 58 | var $mType, $mReason, $mRealName; |
58 | 59 | var $abortError = ''; |
59 | | - var $mUser; |
| 60 | + var $mUser,$mConfirmationMailStatus,$mRunCookieRedirect,$mRunCreationConfirmation; |
60 | 61 | |
61 | 62 | /** |
62 | 63 | * @var ExternalUser |
— | — | @@ -187,12 +188,6 @@ |
188 | 189 | function addNewAccount($mUser) { |
189 | 190 | global $wgUser, $wgEmailAuthentication, $wgOut; |
190 | 191 | |
191 | | - # Create the account and abort if there's a problem doing so |
192 | | - //$mUser = $this->addNewAccountInternal(); |
193 | | - if( $mUser == null ) { |
194 | | - return; |
195 | | - } |
196 | | - |
197 | 192 | # If we showed up language selection links, and one was in use, be |
198 | 193 | # smart (and sensible) and save that language as the user's preference |
199 | 194 | global $wgLoginLanguageSelector; |
— | — | @@ -201,13 +196,8 @@ |
202 | 197 | } |
203 | 198 | |
204 | 199 | # Send out an email authentication message if needed |
205 | | - if( $wgEmailAuthentication && User::isValidEmailAddr( $mUser->getEmail() ) ) { |
206 | | - $status = $mUser->sendConfirmationMail(); |
207 | | - if( $status->isGood() ) { |
208 | | - $wgOut->addWikiMsg( 'confirmemail_oncreate' ); |
209 | | - } else { |
210 | | - $wgOut->addWikiText( $status->getWikiText( 'confirmemail_sendfailed' ) ); |
211 | | - } |
| 200 | + if( $wgEmailAuthentication ) { |
| 201 | + $this->mConfirmationMailStatus = $mUser->sendConfirmationMail(); |
212 | 202 | } |
213 | 203 | |
214 | 204 | # Save settings (including confirmation token) |
— | — | @@ -222,16 +212,13 @@ |
223 | 213 | wfRunHooks( 'AddNewAccount', array( $wgUser, false ) ); |
224 | 214 | $wgUser->addNewUserLogEntry(); |
225 | 215 | if( $this->hasSessionCookie() ) { |
226 | | - return $this->successfulCreation(); |
| 216 | + return true; |
227 | 217 | } else { |
228 | | - return $this->cookieRedirectCheck( 'new' ); |
| 218 | + $this->mRunCookieRedirect = true; |
| 219 | + return true; |
229 | 220 | } |
230 | 221 | } else { |
231 | | - # Confirm that the account was created |
232 | | - $self = SpecialPage::getTitleFor( 'Userlogin' ); |
233 | | - $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) ); |
234 | | - $wgOut->addWikiMsg( 'accountcreatedtext', $mUser->getName() ); |
235 | | - $wgOut->returnToMain( false, $self ); |
| 222 | + $this->mRunCreationConfirmation = true; |
236 | 223 | wfRunHooks( 'AddNewAccount', array( $mUser, false ) ); |
237 | 224 | $mUser->addNewUserLogEntry( false, $this->mReason ); |
238 | 225 | return true; |
— | — | @@ -274,17 +261,18 @@ |
275 | 262 | self::setCreateaccountToken(); |
276 | 263 | return self::NO_COOKIES; |
277 | 264 | } |
278 | | - |
| 265 | + |
279 | 266 | # The user didn't pass a createaccount token |
280 | 267 | if ( !$this->mToken ) { |
281 | 268 | return self::NEED_TOKEN; |
282 | 269 | } |
283 | 270 | |
| 271 | + |
284 | 272 | # Validate the createaccount token |
285 | 273 | if ( $this->mToken !== self::getCreateaccountToken() ) { |
286 | 274 | return self::WRONG_TOKEN; |
287 | 275 | } |
288 | | - |
| 276 | + |
289 | 277 | # Check permissions |
290 | 278 | if ( !$wgUser->isAllowed( 'createaccount' ) ) { |
291 | 279 | return self::INSUFFICIENT_PERMISSION; |
— | — | @@ -364,8 +352,12 @@ |
365 | 353 | |
366 | 354 | self::clearCreateaccountToken(); |
367 | 355 | $mUser = $this->initUser( $mUser, false ); |
368 | | - $this->addNewAccount($mUser); |
369 | | - return self::SUCCESS; |
| 356 | + if( $mUser == null ) { |
| 357 | + return self::INIT_FAILED; |
| 358 | + } |
| 359 | + |
| 360 | + $this->addNewAccount($mUser); |
| 361 | + return self::SUCCESS; |
370 | 362 | } |
371 | 363 | |
372 | 364 | /** |
— | — | @@ -411,12 +403,28 @@ |
412 | 404 | } |
413 | 405 | |
414 | 406 | function processSignup() { |
415 | | - global $wgUser, $wgOut; |
| 407 | + global $wgUser, $wgOut, $wgEmailAuthentication; |
416 | 408 | |
417 | 409 | switch ( $this->addNewAccountInternal() ) { |
418 | 410 | case self::SUCCESS: |
419 | | - //$this->initUser( $mUser, false ); |
420 | | - //$this->addNewAccount($mUser); |
| 411 | + if( $wgEmailAuthentication ) { |
| 412 | + if( $this->mConfirmationMailStatus->isGood() ) { |
| 413 | + $wgOut->addWikiMsg( 'confirmemail_oncreate' ); |
| 414 | + } else { |
| 415 | + $wgOut->addWikiText( $this->mConfirmationMailStatus->getWikiText( 'confirmemail_sendfailed' ) ); |
| 416 | + } |
| 417 | + } |
| 418 | + if( $this->mRunCookieRedirect ) { |
| 419 | + $this->cookieRedirectCheck( 'new' ); |
| 420 | + } |
| 421 | + # Confirm that the account was created |
| 422 | + if($this->mRunCreationConfirmation) { |
| 423 | + $self = SpecialPage::getTitleFor( 'Userlogin' ); |
| 424 | + $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) ); |
| 425 | + $wgOut->addWikiMsg( 'accountcreatedtext', $mUser->getName() ); |
| 426 | + $wgOut->returnToMain( false, $self ); |
| 427 | + } |
| 428 | + $this->successfulCreation(); |
421 | 429 | break; |
422 | 430 | case self::INVALID_DOMAIN: |
423 | 431 | $this->mainSignupForm( wfMsg( 'wrongpassword' ) ); |
— | — | @@ -475,10 +483,13 @@ |
476 | 484 | case self::EXTR_DB_ERROR: |
477 | 485 | $this->mainSignupForm( wfMsg( 'externaldberror' ) ); |
478 | 486 | break; |
479 | | - case self::THROTLLED; |
| 487 | + case self::THROTLLED: |
480 | 488 | global $wgAccountCreationThrottle; |
481 | 489 | $this->mainSignupForm( wfMsgExt( 'acct_creation_throttle_hit', array( 'parseinline' ), $wgAccountCreationThrottle ) ); |
482 | 490 | break; |
| 491 | + case self::INIT_FAILED: |
| 492 | + $this->mainSignupForm( wfMsg( 'init_failed' ) ); |
| 493 | + break; |
483 | 494 | default: |
484 | 495 | throw new MWException( 'Unhandled case value' ); |
485 | 496 | } |
— | — | @@ -602,7 +613,7 @@ |
603 | 614 | if ( $wgUser->isLoggedIn() ) { |
604 | 615 | $this->mUsername = $wgUser->getName(); |
605 | 616 | } else { |
606 | | - //$this->mUsername = $wgRequest->getCookie( 'UserName' ); |
| 617 | + $this->mUsername = $wgRequest->getCookie( 'UserName' ); |
607 | 618 | } |
608 | 619 | } |
609 | 620 | |