Allow API action=logout with BotPasswords
authorBrad Jorsch <bjorsch@wikimedia.org>
Mon, 29 Feb 2016 17:12:17 +0000 (12:12 -0500)
committerGergő Tisza <gtisza@wikimedia.org>
Tue, 1 Mar 2016 02:26:45 +0000 (02:26 +0000)
Since login is handled specially, do the same for logout.

Bug: T128335
Change-Id: Ib3b12d7045449b5c44f5ff7d1ecfce14416e8400

includes/api/ApiLogout.php

index 2c38208..6a26e2e 100644 (file)
@@ -24,6 +24,8 @@
  * @file
  */
 
+use MediaWiki\Session\BotPasswordSessionProvider;
+
 /**
  * API module to allow users to log out of the wiki. API equivalent of
  * Special:Userlogout.
 class ApiLogout extends ApiBase {
 
        public function execute() {
-               // Make sure it's possible to log out
                $session = MediaWiki\Session\SessionManager::getGlobalSession();
+
+               // Handle bot password logout specially
+               if ( $session->getProvider() instanceof BotPasswordSessionProvider ) {
+                       $session->unpersist();
+                       return;
+               }
+
+               // Make sure it's possible to log out
                if ( !$session->canSetUser() ) {
                        $this->dieUsage(
                                'Cannot log out when using ' .