$loginForm = new LoginForm();
$loginForm->setContext( $context );
- global $wgCookiePrefix, $wgPasswordAttemptThrottle;
-
$authRes = $loginForm->authenticateUserData();
switch ( $authRes ) {
case LoginForm::SUCCESS:
$result['lguserid'] = intval( $user->getId() );
$result['lgusername'] = $user->getName();
$result['lgtoken'] = $user->getToken();
- $result['cookieprefix'] = $wgCookiePrefix;
+ $result['cookieprefix'] = $this->getConfig()->get( 'CookiePrefix' );
$result['sessionid'] = session_id();
break;
case LoginForm::NEED_TOKEN:
$result['result'] = 'NeedToken';
$result['token'] = $loginForm->getLoginToken();
- $result['cookieprefix'] = $wgCookiePrefix;
+ $result['cookieprefix'] = $this->getConfig()->get( 'CookiePrefix' );
$result['sessionid'] = session_id();
break;
case LoginForm::THROTTLED:
$result['result'] = 'Throttled';
- $result['wait'] = intval( $wgPasswordAttemptThrottle['seconds'] );
+ $throttle = $this->getConfig()->get( 'PasswordAttemptThrottle' );
+ $result['wait'] = intval( $throttle['seconds'] );
break;
case LoginForm::USER_BLOCKED:
);
}
- public function getResultProperties() {
- return array(
- '' => array(
- 'result' => array(
- ApiBase::PROP_TYPE => array(
- 'Success',
- 'NeedToken',
- 'WrongToken',
- 'NoName',
- 'Illegal',
- 'WrongPluginPass',
- 'NotExists',
- 'WrongPass',
- 'EmptyPass',
- 'CreateBlocked',
- 'Throttled',
- 'Blocked',
- 'Aborted'
- )
- ),
- 'lguserid' => array(
- ApiBase::PROP_TYPE => 'integer',
- ApiBase::PROP_NULLABLE => true
- ),
- 'lgusername' => array(
- ApiBase::PROP_TYPE => 'string',
- ApiBase::PROP_NULLABLE => true
- ),
- 'lgtoken' => array(
- ApiBase::PROP_TYPE => 'string',
- ApiBase::PROP_NULLABLE => true
- ),
- 'cookieprefix' => array(
- ApiBase::PROP_TYPE => 'string',
- ApiBase::PROP_NULLABLE => true
- ),
- 'sessionid' => array(
- ApiBase::PROP_TYPE => 'string',
- ApiBase::PROP_NULLABLE => true
- ),
- 'token' => array(
- ApiBase::PROP_TYPE => 'string',
- ApiBase::PROP_NULLABLE => true
- ),
- 'details' => array(
- ApiBase::PROP_TYPE => 'string',
- ApiBase::PROP_NULLABLE => true
- ),
- 'wait' => array(
- ApiBase::PROP_TYPE => 'integer',
- ApiBase::PROP_NULLABLE => true
- ),
- 'reason' => array(
- ApiBase::PROP_TYPE => 'string',
- ApiBase::PROP_NULLABLE => true
- )
- )
- );
- }
-
public function getDescription() {
return array(
'Log in and get the authentication tokens.',
);
}
- public function getPossibleErrors() {
- return array_merge( parent::getPossibleErrors(), array(
- array(
- 'code' => 'NeedToken', 'info' => 'You need to resubmit your ' .
- 'login with the specified token. See ' .
- 'https://bugzilla.wikimedia.org/show_bug.cgi?id=23076'
- ),
- array( 'code' => 'WrongToken', 'info' => 'You specified an invalid token' ),
- array( 'code' => 'NoName', 'info' => 'You didn\'t set the lgname parameter' ),
- array( 'code' => 'Illegal', 'info' => 'You provided an illegal username' ),
- array( 'code' => 'NotExists', 'info' => 'The username you provided doesn\'t exist' ),
- array(
- 'code' => 'EmptyPass',
- 'info' => 'You didn\'t set the lgpassword parameter or you left it empty'
- ),
- array( 'code' => 'WrongPass', 'info' => 'The password you provided is incorrect' ),
- array(
- 'code' => 'WrongPluginPass',
- 'info' => 'Same as "WrongPass", returned when an authentication ' .
- 'plugin rather than MediaWiki itself rejected the password'
- ),
- array(
- 'code' => 'CreateBlocked',
- 'info' => 'The wiki tried to automatically create a new account ' .
- 'for you, but your IP address has been blocked from account creation'
- ),
- array( 'code' => 'Throttled', 'info' => 'You\'ve logged in too many times in a short time' ),
- array( 'code' => 'Blocked', 'info' => 'User is blocked' ),
- ) );
- }
-
public function getExamples() {
return array(
'api.php?action=login&lgname=user&lgpassword=password'