authManager = $authManager; } public function execute() { if ( !$this->getUser()->isNamed() ) { $this->dieWithError( 'apierror-mustbeloggedin-changeauthenticationdata', 'notloggedin' ); } $helper = new ApiAuthManagerHelper( $this, $this->authManager ); // Check security-sensitive operation status $helper->securitySensitiveOperation( 'ChangeCredentials' ); // Fetch the request $reqs = ApiAuthManagerHelper::blacklistAuthenticationRequests( $helper->loadAuthenticationRequests( AuthManager::ACTION_CHANGE ), $this->getConfig()->get( MainConfigNames::ChangeCredentialsBlacklist ) ); if ( count( $reqs ) !== 1 ) { $this->dieWithError( 'apierror-changeauth-norequest', 'badrequest' ); } $req = reset( $reqs ); // Make the change $status = $this->authManager->allowsAuthenticationDataChange( $req, true ); $this->getHookRunner()->onChangeAuthenticationDataAudit( $req, $status ); if ( !$status->isGood() ) { $this->dieStatus( $status ); } $this->authManager->changeAuthenticationData( $req ); $this->getResult()->addValue( null, 'changeauthenticationdata', [ 'status' => 'success' ] ); } public function isWriteMode() { return true; } public function needsToken() { return 'csrf'; } public function getAllowedParams() { return ApiAuthManagerHelper::getStandardParams( AuthManager::ACTION_CHANGE, 'request' ); } public function dynamicParameterDocumentation() { return [ 'api-help-authmanagerhelper-additional-params', AuthManager::ACTION_CHANGE ]; } protected function getExamplesMessages() { return [ 'action=changeauthenticationdata' . '&changeauthrequest=MediaWiki%5CAuth%5CPasswordAuthenticationRequest' . '&password=ExamplePassword&retype=ExamplePassword&changeauthtoken=123ABC' => 'apihelp-changeauthenticationdata-example-password', ]; } public function getHelpUrls() { return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Manage_authentication_data'; } }