summaryrefslogtreecommitdiff
path: root/includes/api/ApiLogin.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiLogin.php')
-rw-r--r--includes/api/ApiLogin.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php
index 5480d940..c66e2156 100644
--- a/includes/api/ApiLogin.php
+++ b/includes/api/ApiLogin.php
@@ -24,6 +24,7 @@
*
* @file
*/
+use MediaWiki\Logger\LoggerFactory;
/**
* Unit to authenticate log-in attempts to the current wiki.
@@ -144,6 +145,10 @@ class ApiLogin extends ApiBase {
case LoginForm::CREATE_BLOCKED:
$result['result'] = 'CreateBlocked';
$result['details'] = 'Your IP address is blocked from account creation';
+ $block = $context->getUser()->getBlock();
+ if ( $block ) {
+ $result = array_merge( $result, ApiQueryUserInfo::getBlockInfo( $block ) );
+ }
break;
case LoginForm::THROTTLED:
@@ -154,6 +159,10 @@ class ApiLogin extends ApiBase {
case LoginForm::USER_BLOCKED:
$result['result'] = 'Blocked';
+ $block = User::newFromName( $params['name'] )->getBlock();
+ if ( $block ) {
+ $result = array_merge( $result, ApiQueryUserInfo::getBlockInfo( $block ) );
+ }
break;
case LoginForm::ABORTED:
@@ -166,6 +175,12 @@ class ApiLogin extends ApiBase {
}
$this->getResult()->addValue( null, 'login', $result );
+
+ LoggerFactory::getInstance( 'authmanager' )->info( 'Login attempt', array(
+ 'event' => 'login',
+ 'successful' => $authRes === LoginForm::SUCCESS,
+ 'status' => LoginForm::$statusCodes[$authRes],
+ ) );
}
public function mustBePosted() {
@@ -179,7 +194,9 @@ class ApiLogin extends ApiBase {
public function getAllowedParams() {
return array(
'name' => null,
- 'password' => null,
+ 'password' => array(
+ ApiBase::PARAM_TYPE => 'password',
+ ),
'domain' => null,
'token' => null,
);