36 parent::__construct( $main, $action );
38 $this->authAction = $action ===
'unlinkaccount'
39 ? AuthManager::ACTION_UNLINK
40 : AuthManager::ACTION_REMOVE;
41 $this->operation = $action ===
'unlinkaccount'
43 :
'RemoveCredentials';
47 if ( !$this->
getUser()->isLoggedIn() ) {
48 $this->
dieWithError(
'apierror-mustbeloggedin-removeauth',
'notloggedin' );
52 $manager = AuthManager::singleton();
59 $blacklist = $this->authAction === AuthManager::ACTION_REMOVE
60 ? array_flip( $this->
getConfig()->
get(
'RemoveCredentialsBlacklist' ) )
63 $manager->getAuthenticationRequests( $this->authAction, $this->getUser() ),
64 function ( $req ) use ( $params, $blacklist ) {
65 return $req->getUniqueId() === $params[
'request'] &&
66 !isset( $blacklist[get_class( $req )] );
69 if ( count( $reqs ) !== 1 ) {
70 $this->
dieWithError(
'apierror-changeauth-norequest',
'badrequest' );
72 $req = reset( $reqs );
75 $status = $manager->allowsAuthenticationDataChange( $req,
true );
76 Hooks::run(
'ChangeAuthenticationDataAudit', [ $req, $status ] );
77 if ( !$status->isGood() ) {
80 $manager->changeAuthenticationData( $req );
103 "action={$action}&request=FooAuthenticationRequest&token=123ABC"
104 =>
"apihelp-{$path}-example-simple",
109 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Manage_authentication_data';
static getStandardParams( $action,... $wantedParams)
Fetch the standard parameters this helper recognizes.
static newForModule(ApiBase $module)
Static version of the constructor, for chaining.
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
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.
This is the main API class, used for both external and internal processing.
Remove authentication data from 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.
__construct(ApiMain $main, $action)
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.