34 parent::__construct( $main, $action,
'changeauth' );
38 if ( !$this->
getUser()->isLoggedIn() ) {
39 $this->
dieWithError(
'apierror-mustbeloggedin-changeauthenticationdata',
'notloggedin' );
42 $manager = MediaWikiServices::getInstance()->getAuthManager();
46 $helper->securitySensitiveOperation(
'ChangeCredentials' );
50 $helper->loadAuthenticationRequests( AuthManager::ACTION_CHANGE ),
51 $this->getConfig()->get(
'ChangeCredentialsBlacklist' )
53 if ( count( $reqs ) !== 1 ) {
54 $this->
dieWithError(
'apierror-changeauth-norequest',
'badrequest' );
56 $req = reset( $reqs );
59 $status = $manager->allowsAuthenticationDataChange( $req,
true );
60 $this->
getHookRunner()->onChangeAuthenticationDataAudit( $req, $status );
61 if ( !$status->isGood() ) {
64 $manager->changeAuthenticationData( $req );
66 $this->
getResult()->addValue(
null,
'changeauthenticationdata', [
'status' =>
'success' ] );
84 return [
'api-help-authmanagerhelper-additional-params', AuthManager::ACTION_CHANGE ];
89 'action=changeauthenticationdata' .
90 '&changeauthrequest=MediaWiki%5CAuth%5CPasswordAuthenticationRequest' .
91 '&password=ExamplePassword&retype=ExamplePassword&changeauthtoken=123ABC'
92 =>
'apihelp-changeauthenticationdata-example-password',
97 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Manage_authentication_data';
Helper class for AuthManager-using API modules.
static getStandardParams( $action,... $wantedParams)
Fetch the standard parameters this helper recognizes.
static blacklistAuthenticationRequests(array $reqs, array $blacklist)
Filter out authentication requests by class name.
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getResult()
Get the result object.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
getHookRunner()
Get an ApiHookRunner for running core API hooks.
Change authentication data with AuthManager.
getExamplesMessages()
Returns usage examples for this module.
getHelpUrls()
Return links to more detailed help pages about the module.
isWriteMode()
Indicates whether this module requires write mode.
needsToken()
Returns the token type this module requires in order to execute.
__construct(ApiMain $main, $action)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
dynamicParameterDocumentation()
Indicate if the module supports dynamically-determined parameters that cannot be included in self::ge...
This is the main API class, used for both external and internal processing.
getUser()
Stable to override.