29 parent::__construct( $main, $action,
'login' );
35 $msgs = parent::getFinalDescription();
36 $msgs[] = $this->
msg(
'api-help-authmanager-general-usage',
40 AuthManager::ACTION_LOGIN,
52 if ( $params[
'returnurl'] !==
null ) {
53 $bits = $this->urlUtils->parse( $params[
'returnurl'] );
54 if ( !$bits || $bits[
'scheme'] ===
'' ) {
57 [
'apierror-badurl', $encParamName,
wfEscapeWikiText( $params[
'returnurl'] ) ],
58 "badurl_{$encParamName}"
63 if ( $params[
'reauthenticate'] !==
null ) {
65 if ( $this->
getUser()->isAnon() ) {
66 $this->
dieWithError(
'apierror-mustbeloggedin-reauthenticate' );
68 $requestOptions[
'securityLevel'] = $params[
'reauthenticate'];
74 if ( !$this->authManager->canAuthenticateNow() ) {
75 $res = AuthenticationResponse::newFail( $this->
msg(
'userlogin-cannot-' . AuthManager::ACTION_LOGIN ) );
76 $this->
getResult()->addValue(
null,
'clientlogin',
77 $helper->formatAuthenticationResponse( $res ) );
78 $helper->logAuthenticationResult(
'login', $performer, $res );
83 if ( $params[
'continue'] ) {
84 $reqs = $helper->loadAuthenticationRequests( AuthManager::ACTION_LOGIN_CONTINUE );
85 $res = $this->authManager->continueAuthentication( $reqs );
87 $reqs = $helper->loadAuthenticationRequests( AuthManager::ACTION_LOGIN, $requestOptions );
88 if ( $params[
'preservestate'] ) {
89 $req = $helper->getPreservedRequest();
94 $res = $this->authManager->beginAuthentication( $reqs, $params[
'returnurl'] );
101 $res->neededRequests, [ CreateFromLoginAuthenticationRequest::class ]
104 $this->
getResult()->addValue(
null,
'clientlogin',
105 $helper->formatAuthenticationResponse( $res ) );
106 $helper->logAuthenticationResult(
'login', $performer, $res );
128 'requests',
'messageformat',
'mergerequestfields',
'preservestate',
'returnurl',
'continue'
130 'reauthenticate' => [
138 return [
'api-help-authmanagerhelper-additional-params', AuthManager::ACTION_LOGIN ];
144 'action=clientlogin&username=Example&password=ExamplePassword&'
145 .
'loginreturnurl=http://example.org/&logintoken=123ABC'
146 =>
'apihelp-clientlogin-example-login',
147 'action=clientlogin&logincontinue=1&OATHToken=987654&logintoken=123ABC'
148 =>
'apihelp-clientlogin-example-login2',
154 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Login';
159class_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()