X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiCreateAccount.php;h=455540b4c5b198e958568debaca0c594be38a416;hb=0c86649f4b683598761eaeb01929984adb373b0b;hp=cfb6dab5972e2954d4169dfdf382e30d49357d42;hpb=aeae6afbbb26c67fd0f20e23d13fa9f3d77420d0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiCreateAccount.php b/includes/api/ApiCreateAccount.php index cfb6dab597..455540b4c5 100644 --- a/includes/api/ApiCreateAccount.php +++ b/includes/api/ApiCreateAccount.php @@ -29,9 +29,12 @@ */ class ApiCreateAccount extends ApiBase { public function execute() { - // If we're in JSON callback mode, no tokens can be obtained - if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) { - $this->dieUsage( 'Cannot create account when using a callback', 'aborted' ); + // If we're in a mode that breaks the same-origin policy, no tokens can + // be obtained + if ( $this->lacksSameOriginSecurity() ) { + $this->dieUsage( + 'Cannot create account when the same-origin policy is not applied', 'aborted' + ); } // $loginForm->addNewaccountInternal will throw exceptions @@ -83,7 +86,7 @@ class ApiCreateAccount extends ApiBase { $loginForm = new LoginForm(); $loginForm->setContext( $context ); - wfRunHooks( 'AddNewAccountApiForm', array( $this, $loginForm ) ); + Hooks::run( 'AddNewAccountApiForm', array( $this, $loginForm ) ); $loginForm->load(); $status = $loginForm->addNewaccountInternal(); @@ -113,7 +116,7 @@ class ApiCreateAccount extends ApiBase { // Save settings (including confirmation token) $user->saveSettings(); - wfRunHooks( 'AddNewAccount', array( $user, $params['mailpassword'] ) ); + Hooks::run( 'AddNewAccount', array( $user, $params['mailpassword'] ) ); if ( $params['mailpassword'] ) { $logAction = 'byemail'; @@ -149,9 +152,9 @@ class ApiCreateAccount extends ApiBase { $warnings = $status->getErrorsByType( 'warning' ); if ( $warnings ) { foreach ( $warnings as &$warning ) { - $apiResult->setIndexedTagName( $warning['params'], 'param' ); + ApiResult::setIndexedTagName( $warning['params'], 'param' ); } - $apiResult->setIndexedTagName( $warnings, 'warning' ); + ApiResult::setIndexedTagName( $warnings, 'warning' ); $result['warnings'] = $warnings; } } else { @@ -160,7 +163,7 @@ class ApiCreateAccount extends ApiBase { } // Give extensions a chance to modify the API result data - wfRunHooks( 'AddNewAccountApiResult', array( $this, $loginForm, &$result ) ); + Hooks::run( 'AddNewAccountApiResult', array( $this, $loginForm, &$result ) ); $apiResult->addValue( null, 'createaccount', $result ); } @@ -200,7 +203,7 @@ class ApiCreateAccount extends ApiBase { ); } - public function getExamplesMessages() { + protected function getExamplesMessages() { return array( 'action=createaccount&name=testuser&password=test123' => 'apihelp-createaccount-example-pass',