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

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