Return comment stuffs
[lhc/web/wiklou.git] / includes / api / ApiLogin.php
index 3cd622b..5eb7ce4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * API for MediaWiki 1.8+
+ *
  *
  * Created on Sep 19, 2006
  *
@@ -70,14 +70,13 @@ class ApiLogin extends ApiBase {
 
                $loginForm = new LoginForm( $req );
 
-               global $wgCookiePrefix;
+               global $wgCookiePrefix, $wgUser, $wgPasswordAttemptThrottle;
 
-               switch ( $authRes = $loginForm->authenticateUserData() ) {
+               $authRes = $loginForm->authenticateUserData();
+               switch ( $authRes ) {
                        case LoginForm::SUCCESS:
-                               global $wgUser;
-
                                $wgUser->setOption( 'rememberpassword', 1 );
-                               $wgUser->setCookies();
+                               $wgUser->setCookies( $this->getMain()->getRequest() );
 
                                // Run hooks. FIXME: split back and frontend from this hook.
                                // FIXME: This hook should be placed in the backend
@@ -134,7 +133,6 @@ class ApiLogin extends ApiBase {
                                break;
 
                        case LoginForm::THROTTLED:
-                               global $wgPasswordAttemptThrottle;
                                $result['result'] = 'Throttled';
                                $result['wait'] = intval( $wgPasswordAttemptThrottle['seconds'] );
                                break;
@@ -143,6 +141,11 @@ class ApiLogin extends ApiBase {
                                $result['result'] = 'Blocked';
                                break;
 
+                       case LoginForm::ABORTED:
+                               $result['result'] = 'Aborted';
+                               $result['reason'] =  $loginForm->mAbortLoginErrorMsg;
+                               break;
+
                        default:
                                ApiBase::dieDebug( __METHOD__, "Unhandled case value: {$authRes}" );
                }
@@ -178,7 +181,7 @@ class ApiLogin extends ApiBase {
 
        public function getDescription() {
                return array(
-                       'This module is used to login and get the authentication tokens. ',
+                       'Log in and get the authentication tokens. ',
                        'In the event of a successful log-in, a cookie will be attached',
                        'to your session. In the event of a failed log-in, you will not ',
                        'be able to attempt another log-in through this method for 5 seconds.',