X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryAuthManagerInfo.php;h=d23d8988f3f82dddf10c71242da895b25e35b76a;hb=9283760f340c6971d748fb574a35453fa7928807;hp=e2229cbe9fa89370fbbece13b0fe93a106019806;hpb=b027651fe665cf5a167ab7c548252027a2c3eeec;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryAuthManagerInfo.php b/includes/api/ApiQueryAuthManagerInfo.php index e2229cbe9f..d23d8988f3 100644 --- a/includes/api/ApiQueryAuthManagerInfo.php +++ b/includes/api/ApiQueryAuthManagerInfo.php @@ -1,6 +1,6 @@ + * Copyright © 2016 Wikimedia Foundation and contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,7 +43,6 @@ class ApiQueryAuthManagerInfo extends ApiQueryBase { 'canauthenticatenow' => $manager->canAuthenticateNow(), 'cancreateaccounts' => $manager->canCreateAccounts(), 'canlinkaccounts' => $manager->canLinkAccounts(), - 'haspreservedstate' => $helper->getPreservedRequest() !== null, ]; if ( $params['securitysensitiveoperation'] !== null ) { @@ -53,10 +52,27 @@ class ApiQueryAuthManagerInfo extends ApiQueryBase { } if ( $params['requestsfor'] ) { - $reqs = $manager->getAuthenticationRequests( $params['requestsfor'], $this->getUser() ); + $action = $params['requestsfor']; + + $preservedReq = $helper->getPreservedRequest(); + if ( $preservedReq ) { + $ret += [ + 'haspreservedstate' => $preservedReq->hasStateForAction( $action ), + 'hasprimarypreservedstate' => $preservedReq->hasPrimaryStateForAction( $action ), + 'preservedusername' => (string)$preservedReq->username, + ]; + } else { + $ret += [ + 'haspreservedstate' => false, + 'hasprimarypreservedstate' => false, + 'preservedusername' => '', + ]; + } + + $reqs = $manager->getAuthenticationRequests( $action, $this->getUser() ); // Filter out blacklisted requests, depending on the action - switch ( $params['requestsfor'] ) { + switch ( $action ) { case AuthManager::ACTION_CHANGE: $reqs = ApiAuthManagerHelper::blacklistAuthenticationRequests( $reqs, $this->getConfig()->get( 'ChangeCredentialsBlacklist' ) @@ -101,16 +117,16 @@ class ApiQueryAuthManagerInfo extends ApiQueryBase { protected function getExamplesMessages() { return [ 'action=query&meta=authmanagerinfo&amirequestsfor=' . urlencode( AuthManager::ACTION_LOGIN ) - => 'apihelp-query+filerepoinfo-example-login', + => 'apihelp-query+authmanagerinfo-example-login', 'action=query&meta=authmanagerinfo&amirequestsfor=' . urlencode( AuthManager::ACTION_LOGIN ) . '&amimergerequestfields=1' - => 'apihelp-query+filerepoinfo-example-login-merged', + => 'apihelp-query+authmanagerinfo-example-login-merged', 'action=query&meta=authmanagerinfo&amisecuritysensitiveoperation=foo' - => 'apihelp-query+filerepoinfo-example-securitysensitiveoperation', + => 'apihelp-query+authmanagerinfo-example-securitysensitiveoperation', ]; } public function getHelpUrls() { - return 'https://www.mediawiki.org/wiki/API:Authmanagerinfo'; + return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Authmanagerinfo'; } }