Return captcha information via createaccount API only if no other errors

Bug: 61704
Change-Id: I707aab2c0accff8ab5a36666c49815106356b2c7
This commit is contained in:
Max Semenik 2014-03-13 02:37:17 +04:00
parent a32cd4f168
commit 8a336ddd9a

View file

@ -828,18 +828,18 @@ class SimpleCaptcha {
* Pass extra data back in API results for account creation. * Pass extra data back in API results for account creation.
* *
* @param ApiCreateAccount $apiModule * @param ApiCreateAccount $apiModule
* @param LoginForm &loginForm * @param LoginForm &loginPage
* @param array &$params * @param array &$result
* @return hook return value * @return bool: Hook return value
*/ */
function addNewAccountApiResult( $apiModule, $loginPage, &$result ) { function addNewAccountApiResult( $apiModule, $loginPage, &$result ) {
if ( $result['result'] !== 'Success' && $this->needCreateAccountCaptcha() ) { if ( $result['result'] !== 'Success' && $this->needCreateAccountCaptcha() ) {
$this->addCaptchaAPI( $result );
// If we failed a captcha, override the generic 'Warning' result string // If we failed a captcha, override the generic 'Warning' result string
if ( $result['result'] === 'Warning' && isset( $result['warnings'] ) ) { if ( $result['result'] === 'Warning' && isset( $result['warnings'] ) ) {
foreach ( $result['warnings'] as $warning ) { foreach ( $result['warnings'] as $warning ) {
if ( $warning['message'] === 'captcha-createaccount-fail' ) { if ( $warning['message'] === 'captcha-createaccount-fail' ) {
$this->addCaptchaAPI( $result );
$result['result'] = 'NeedCaptcha'; $result['result'] = 'NeedCaptcha';
} }
} }