return;
}
- try {
- $this->requirePostedParameters( [ 'password', 'token' ] );
- } catch ( UsageException $ex ) {
- // Make this a warning for now, upgrade to an error in 1.29.
- $this->setWarning( $ex->getMessage() );
- $this->logFeatureUsage( 'login-params-in-query-string' );
- }
+ $this->requirePostedParameters( [ 'password', 'token' ] );
$params = $this->extractRequestParams();
switch ( $res->status ) {
case AuthenticationResponse::PASS:
if ( $this->getConfig()->get( 'EnableBotPasswords' ) ) {
- $warn = 'Main-account login via action=login is deprecated and may stop working ' .
- 'without warning.';
- $warn .= ' To continue login with action=login, see [[Special:BotPasswords]].';
- $warn .= ' To safely continue using main-account login, see action=clientlogin.';
+ $this->addDeprecation( 'apiwarn-deprecation-login-botpw', 'main-account-login' );
} else {
- $warn = 'Login via action=login is deprecated and may stop working without warning.';
- $warn .= ' To safely log in, see action=clientlogin.';
+ $this->addDeprecation( 'apiwarn-deprecation-login-nobotpw', 'main-account-login' );
}
- $this->setWarning( $warn );
$authRes = 'Success';
$loginType = 'AuthManager';
break;
case 'NeedToken':
$result['token'] = $token->toString();
- $this->setWarning( 'Fetching a token via action=login is deprecated. ' .
- 'Use action=query&meta=tokens&type=login instead.' );
- $this->logFeatureUsage( 'action=login&!lgtoken' );
+ $this->addDeprecation( 'apiwarn-deprecation-login-token', 'action=login&!lgtoken' );
break;
case 'WrongToken':
break;
case 'Failed':
- $result['reason'] = $message->useDatabase( 'false' )->inLanguage( 'en' )->text();
+ $errorFormatter = $this->getErrorFormatter();
+ if ( $errorFormatter instanceof ApiErrorFormatter_BackCompat ) {
+ $result['reason'] = ApiErrorFormatter::stripMarkup(
+ $message->useDatabase( false )->inLanguage( 'en' )->text()
+ );
+ } else {
+ $result['reason'] = $errorFormatter->formatMessage( $message );
+ }
break;
case 'Aborted':
$result['reason'] = 'Authentication requires user interaction, ' .
- 'which is not supported by action=login.';
+ 'which is not supported by action=login.';
if ( $this->getConfig()->get( 'EnableBotPasswords' ) ) {
$result['reason'] .= ' To be able to login with action=login, see [[Special:BotPasswords]].';
$result['reason'] .= ' To continue using main-account login, see action=clientlogin.';
'token' => [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => false, // for BC
+ ApiBase::PARAM_SENSITIVE => true,
ApiBase::PARAM_HELP_MSG => [ 'api-help-param-token', 'login' ],
],
];
}
public function getHelpUrls() {
- return 'https://www.mediawiki.org/wiki/API:Login';
+ return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Login';
}
/**