api: Inject services into ApiQueryAuthManagerInfo
Bug: T259960 Change-Id: I2004426a52baf14ae11df94752cb3a69ceaad6f0
This commit is contained in:
parent
15e80ed8b8
commit
11286edd1a
2 changed files with 26 additions and 10 deletions
|
|
@ -200,7 +200,12 @@ class ApiQuery extends ApiBase {
|
|||
*/
|
||||
private const QUERY_META_MODULES = [
|
||||
'allmessages' => ApiQueryAllMessages::class,
|
||||
'authmanagerinfo' => ApiQueryAuthManagerInfo::class,
|
||||
'authmanagerinfo' => [
|
||||
'class' => ApiQueryAuthManagerInfo::class,
|
||||
'services' => [
|
||||
'AuthManager',
|
||||
]
|
||||
],
|
||||
'siteinfo' => [
|
||||
'class' => ApiQuerySiteinfo::class,
|
||||
'services' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
|
||||
use MediaWiki\Auth\AuthManager;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* A query action to return meta information about AuthManager state.
|
||||
|
|
@ -31,22 +30,34 @@ use MediaWiki\MediaWikiServices;
|
|||
*/
|
||||
class ApiQueryAuthManagerInfo extends ApiQueryBase {
|
||||
|
||||
public function __construct( ApiQuery $query, $moduleName ) {
|
||||
/** @var AuthManager */
|
||||
private $authManager;
|
||||
|
||||
/**
|
||||
* @param ApiQuery $query
|
||||
* @param string $moduleName
|
||||
* @param AuthManager $authManager
|
||||
*/
|
||||
public function __construct(
|
||||
ApiQuery $query,
|
||||
$moduleName,
|
||||
AuthManager $authManager
|
||||
) {
|
||||
parent::__construct( $query, $moduleName, 'ami' );
|
||||
$this->authManager = $authManager;
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$params = $this->extractRequestParams();
|
||||
$manager = MediaWikiServices::getInstance()->getAuthManager();
|
||||
$helper = new ApiAuthManagerHelper( $this, $manager );
|
||||
$helper = new ApiAuthManagerHelper( $this, $this->authManager );
|
||||
$ret = [
|
||||
'canauthenticatenow' => $manager->canAuthenticateNow(),
|
||||
'cancreateaccounts' => $manager->canCreateAccounts(),
|
||||
'canlinkaccounts' => $manager->canLinkAccounts(),
|
||||
'canauthenticatenow' => $this->authManager->canAuthenticateNow(),
|
||||
'cancreateaccounts' => $this->authManager->canCreateAccounts(),
|
||||
'canlinkaccounts' => $this->authManager->canLinkAccounts(),
|
||||
];
|
||||
|
||||
if ( $params['securitysensitiveoperation'] !== null ) {
|
||||
$ret['securitysensitiveoperationstatus'] = $manager->securitySensitiveOperationStatus(
|
||||
$ret['securitysensitiveoperationstatus'] = $this->authManager->securitySensitiveOperationStatus(
|
||||
$params['securitysensitiveoperation']
|
||||
);
|
||||
}
|
||||
|
|
@ -69,7 +80,7 @@ class ApiQueryAuthManagerInfo extends ApiQueryBase {
|
|||
];
|
||||
}
|
||||
|
||||
$reqs = $manager->getAuthenticationRequests( $action, $this->getUser() );
|
||||
$reqs = $this->authManager->getAuthenticationRequests( $action, $this->getUser() );
|
||||
|
||||
// Filter out blacklisted requests, depending on the action
|
||||
switch ( $action ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue