49 parent::__construct( $main, $action );
51 $this->authAction = $action ===
'unlinkaccount'
52 ? AuthManager::ACTION_UNLINK
53 : AuthManager::ACTION_REMOVE;
54 $this->operation = $action ===
'unlinkaccount'
56 :
'RemoveCredentials';
58 $this->authManager = $authManager;
62 if ( !$this->
getUser()->isNamed() ) {
63 $this->
dieWithError(
'apierror-mustbeloggedin-removeauth',
'notloggedin' );
70 ->securitySensitiveOperation( $this->operation );
74 $remove = $this->authAction === AuthManager::ACTION_REMOVE
75 ? array_fill_keys( $this->
getConfig()->
get(
76 MainConfigNames::RemoveCredentialsBlacklist ),
true )
79 $this->authManager->getAuthenticationRequests( $this->authAction, $this->getUser() ),
81 return $req->
getUniqueId() === $params[
'request'] &&
82 !isset( $remove[get_class( $req )] );
85 if ( count( $reqs ) !== 1 ) {
86 $this->
dieWithError(
'apierror-changeauth-norequest',
'badrequest' );
88 $req = reset( $reqs );
91 $status = $this->authManager->allowsAuthenticationDataChange( $req,
true );
92 $this->
getHookRunner()->onChangeAuthenticationDataAudit( $req, $status );
93 if ( !$status->isGood() ) {
96 $this->authManager->changeAuthenticationData( $req );
119 "action={$action}&request=FooAuthenticationRequest&token=123ABC"
120 =>
"apihelp-{$path}-example-simple",
125 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Manage_authentication_data';
static newForModule(ApiBase $module, AuthManager $authManager=null)
Static version of the constructor, for chaining.
static getStandardParams( $action,... $wantedParams)
Fetch the standard parameters this helper recognizes.
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.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModulePath()
Get the path to this module.
getModuleName()
Get the name of the module being executed by this instance.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
getHookRunner()
Get an ApiHookRunner for running core API hooks.
This is the main API class, used for both external and internal processing.
Remove authentication data from AuthManager.
__construct(ApiMain $main, $action, AuthManager $authManager)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
isWriteMode()
Indicates whether this module requires write mode.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getHelpUrls()
Return links to more detailed help pages about the module.
getExamplesMessages()
Returns usage examples for this module.
needsToken()
Returns the token type this module requires in order to execute.
A class containing constants representing the names of configuration variables.