mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-11-24 00:05:24 +00:00
Remove TwoFactorIsEnabled hook handler
Hook was part of Extension:OpenStackManager, but removed by REL1_35, so unnecessary I4741fcb073f8463f017bc1b477206dee801b662b / 46d9149c2db7c2b2d4573bede74b54779d66bee8 Change-Id: I2c5f99bfa9028c57a1eadbd81a51f84b47668848
This commit is contained in:
parent
ec1c1dcb22
commit
37d2b0ff19
|
@ -42,7 +42,6 @@
|
|||
},
|
||||
"Hooks": {
|
||||
"AuthChangeFormFields": "\\MediaWiki\\Extension\\OATHAuth\\Hook\\AuthChangeFormFields\\TOTPExtendTokenField::callback",
|
||||
"TwoFactorIsEnabled": "\\MediaWiki\\Extension\\OATHAuth\\Hook\\TwoFactorIsEnabled\\SetIsEnabled::callback",
|
||||
"LoadExtensionSchemaUpdates": "\\MediaWiki\\Extension\\OATHAuth\\Hook\\LoadExtensionSchemaUpdates\\UpdateTables::callback",
|
||||
"GetPreferences": "\\MediaWiki\\Extension\\OATHAuth\\Hook\\GetPreferences\\AuthModule::callback",
|
||||
"getUserPermissionsErrors": "\\MediaWiki\\Extension\\OATHAuth\\Hook\\GetUserPermissionsErrors\\CheckExclusiveRights::callback"
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\OATHAuth\Hook\TwoFactorIsEnabled;
|
||||
|
||||
use MediaWiki\Extension\OATHAuth\OATHUser;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use RequestContext;
|
||||
|
||||
class SetIsEnabled {
|
||||
/**
|
||||
* @var OATHUser
|
||||
*/
|
||||
protected $authUser;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isEnabled;
|
||||
|
||||
/**
|
||||
* @param bool &$isEnabled
|
||||
* @return bool
|
||||
*/
|
||||
public static function callback( &$isEnabled ) {
|
||||
$userRepo = MediaWikiServices::getInstance()->getService( 'OATHUserRepository' );
|
||||
$authUser = $userRepo->findByUser( RequestContext::getMain()->getUser() );
|
||||
$handler = new static( $authUser, $isEnabled );
|
||||
return $handler->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* SetIsEnabled constructor.
|
||||
* @param OATHUser $authUser
|
||||
* @param bool &$isEnabled
|
||||
*/
|
||||
protected function __construct( $authUser, &$isEnabled ) {
|
||||
$this->authUser = $authUser;
|
||||
$this->isEnabled = &$isEnabled;
|
||||
}
|
||||
|
||||
protected function execute() {
|
||||
if ( $this->authUser && $this->authUser->getModule() !== null ) {
|
||||
$this->isEnabled = true;
|
||||
# This two-factor extension is enabled by the user,
|
||||
# we don't need to check others.
|
||||
return false;
|
||||
} else {
|
||||
$this->isEnabled = false;
|
||||
# This two-factor extension isn't enabled by the user,
|
||||
# but others may be.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue