Merge "mediawiki.api.upload: Use this.defaults.parameters instead of all-custom params"
[lhc/web/wiklou.git] / includes / api / ApiLogin.php
index d8b390c..8c65310 100644 (file)
@@ -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';
+                               $result = array_merge(
+                                       $result,
+                                       ApiQueryUserInfo::getBlockInfo( $context->getUser()->getBlock() )
+                               );
                                break;
 
                        case LoginForm::THROTTLED:
@@ -154,6 +159,10 @@ class ApiLogin extends ApiBase {
 
                        case LoginForm::USER_BLOCKED:
                                $result['result'] = 'Blocked';
+                               $result = array_merge(
+                                       $result,
+                                       ApiQueryUserInfo::getBlockInfo( User::newFromName( $params['name'] )->getBlock() )
+                               );
                                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() {