getUser()->isLoggedIn() ) { $this->dieWithError( 'apierror-mustbeloggedin-changeauthenticationdata', 'notloggedin' ); } $helper = new ApiAuthManagerHelper( $this ); $manager = AuthManager::singleton(); // Check security-sensitive operation status $helper->securitySensitiveOperation( 'ChangeCredentials' ); // Fetch the request $reqs = ApiAuthManagerHelper::blacklistAuthenticationRequests( $helper->loadAuthenticationRequests( AuthManager::ACTION_CHANGE ), $this->getConfig()->get( 'ChangeCredentialsBlacklist' ) ); if ( count( $reqs ) !== 1 ) { $this->dieWithError( 'apierror-changeauth-norequest', 'badrequest' ); } $req = reset( $reqs ); // Make the change $status = $manager->allowsAuthenticationDataChange( $req, true ); Hooks::run( 'ChangeAuthenticationDataAudit', [ $req, $status ] ); if ( !$status->isGood() ) { $this->dieStatus( $status ); } $manager->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'; } }