32 parent::__construct( $main, $action,
'login' );
33 $this->authManager = $authManager;
34 $this->urlUtils = $urlUtils;
40 $msgs = parent::getFinalDescription();
41 $msgs[] = $this->
msg(
'api-help-authmanager-general-usage',
45 AuthManager::ACTION_LOGIN,
57 if ( $params[
'returnurl'] !==
null ) {
58 $bits = $this->urlUtils->parse( $params[
'returnurl'] );
59 if ( !$bits || $bits[
'scheme'] ===
'' ) {
62 [
'apierror-badurl', $encParamName,
wfEscapeWikiText( $params[
'returnurl'] ) ],
63 "badurl_{$encParamName}"
71 if ( !$this->authManager->canAuthenticateNow() ) {
72 $res = AuthenticationResponse::newFail( $this->
msg(
'userlogin-cannot-' . AuthManager::ACTION_LOGIN ) );
73 $this->
getResult()->addValue(
null,
'clientlogin',
74 $helper->formatAuthenticationResponse( $res ) );
75 $helper->logAuthenticationResult(
'login', $performer, $res );
80 if ( $params[
'continue'] ) {
81 $reqs = $helper->loadAuthenticationRequests( AuthManager::ACTION_LOGIN_CONTINUE );
82 $res = $this->authManager->continueAuthentication( $reqs );
84 $reqs = $helper->loadAuthenticationRequests( AuthManager::ACTION_LOGIN );
85 if ( $params[
'preservestate'] ) {
86 $req = $helper->getPreservedRequest();
91 $res = $this->authManager->beginAuthentication( $reqs, $params[
'returnurl'] );
98 $res->neededRequests, [ CreateFromLoginAuthenticationRequest::class ]
101 $this->
getResult()->addValue(
null,
'clientlogin',
102 $helper->formatAuthenticationResponse( $res ) );
103 $helper->logAuthenticationResult(
'login', $performer, $res );
125 'requests',
'messageformat',
'mergerequestfields',
'preservestate',
'returnurl',
'continue'
131 return [
'api-help-authmanagerhelper-additional-params', AuthManager::ACTION_LOGIN ];
137 'action=clientlogin&username=Example&password=ExamplePassword&'
138 .
'loginreturnurl=http://example.org/&logintoken=123ABC'
139 =>
'apihelp-clientlogin-example-login',
140 'action=clientlogin&logincontinue=1&OATHToken=987654&logintoken=123ABC'
141 =>
'apihelp-clientlogin-example-login2',
147 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Login';
152class_alias( ApiClientLogin::class,
'ApiClientLogin' );
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()