31 parent::__construct( $main, $action,
'link' );
32 $this->authManager = $authManager;
33 $this->urlUtils = $urlUtils;
39 $msgs = parent::getFinalDescription();
40 $msgs[] = $this->
msg(
'api-help-authmanager-general-usage',
44 AuthManager::ACTION_LINK,
51 if ( !$this->
getUser()->isNamed() ) {
52 $this->
dieWithError(
'apierror-mustbeloggedin-linkaccounts',
'notloggedin' );
59 if ( $params[
'returnurl'] !==
null ) {
60 $bits = $this->urlUtils->parse( $params[
'returnurl'] );
61 if ( !$bits || $bits[
'scheme'] ===
'' ) {
64 [
'apierror-badurl', $encParamName,
wfEscapeWikiText( $params[
'returnurl'] ) ],
65 "badurl_{$encParamName}"
73 $helper->securitySensitiveOperation(
'LinkAccounts' );
76 if ( !$this->authManager->canLinkAccounts() ) {
77 $this->
getResult()->addValue(
null,
'linkaccount', $helper->formatAuthenticationResponse(
78 AuthenticationResponse::newFail( $this->msg(
'userlogin-cannot-' . AuthManager::ACTION_LINK ) )
84 if ( $params[
'continue'] ) {
85 $reqs = $helper->loadAuthenticationRequests( AuthManager::ACTION_LINK_CONTINUE );
86 $res = $this->authManager->continueAccountLink( $reqs );
88 $reqs = $helper->loadAuthenticationRequests( AuthManager::ACTION_LINK );
89 $res = $this->authManager->beginAccountLink( $this->
getUser(), $reqs, $params[
'returnurl'] );
92 $this->
getResult()->addValue(
null,
'linkaccount',
93 $helper->formatAuthenticationResponse( $res ) );
114 'requests',
'messageformat',
'mergerequestfields',
'returnurl',
'continue'
120 return [
'api-help-authmanagerhelper-additional-params', AuthManager::ACTION_LINK ];
126 'action=linkaccount&provider=Example&linkreturnurl=http://example.org/&linktoken=123ABC'
127 =>
'apihelp-linkaccount-example-link',
133 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Linkaccount';
138class_alias( ApiLinkAccount::class,
'ApiLinkAccount' );
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
This is the main API class, used for both external and internal processing.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()