Track key authentication metrics
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
index 4ca07fe..f446a98 100644 (file)
@@ -20,6 +20,7 @@
  * @file
  * @ingroup SpecialPage
  */
+use MediaWiki\Logger\LoggerFactory;
 
 /**
  * Implements Special:UserLogin
@@ -338,6 +339,10 @@ class LoginForm extends SpecialPage {
                }
 
                $status = $this->addNewAccountInternal();
+               LoggerFactory::getInstance( 'authmanager' )->info( 'Account creation attempt with mailed password', array(
+                       'event' => 'accountcreation',
+                       'status' => $status,
+               ) );
                if ( !$status->isGood() ) {
                        $error = $status->getMessage();
                        $this->mainLoginForm( $error->toString() );
@@ -375,6 +380,11 @@ class LoginForm extends SpecialPage {
 
                # Create the account and abort if there's a problem doing so
                $status = $this->addNewAccountInternal();
+               LoggerFactory::getInstance( 'authmanager' )->info( 'Account creation attempt', array(
+                       'event' => 'accountcreation',
+                       'status' => $status,
+               ) );
+
                if ( !$status->isGood() ) {
                        $error = $status->getMessage();
                        $this->mainLoginForm( $error->toString() );
@@ -911,7 +921,8 @@ class LoginForm extends SpecialPage {
                global $wgMemc, $wgLang, $wgSecureLogin, $wgPasswordAttemptThrottle,
                        $wgInvalidPasswordReset;
 
-               switch ( $this->authenticateUserData() ) {
+               $status = $this->authenticateUserData();
+               switch ( $status ) {
                        case self::SUCCESS:
                                # We've verified now, update the real record
                                $user = $this->getUser();
@@ -1034,6 +1045,12 @@ class LoginForm extends SpecialPage {
                        default:
                                throw new MWException( 'Unhandled case value' );
                }
+
+               LoggerFactory::getInstance( 'authmanager' )->info( 'Login attempt', array(
+                       'event' => 'login',
+                       'successful' => $status === self::SUCCESS,
+                       'status' => $status,
+               ) );
        }
 
        /**
@@ -1390,6 +1407,7 @@ class LoginForm extends SpecialPage {
                        : is_array( $wgPasswordResetRoutes ) && in_array( true, array_values( $wgPasswordResetRoutes ) );
 
                $template->set( 'header', '' );
+               $template->set( 'formheader', '' );
                $template->set( 'skin', $this->getSkin() );
                $template->set( 'name', $this->mUsername );
                $template->set( 'password', $this->mPassword );