mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-11-24 08:14:15 +00:00
Improve ManageForm
Make sure that particular form is only loaded when it actually makes sense for it to load, not when its just requested. Bug: T218211 Change-Id: Ibae0279451b4a6a4a1d1ce212bbbbf919900a46d
This commit is contained in:
parent
4b06d3a66a
commit
36485440ee
|
@ -4,6 +4,7 @@ namespace MediaWiki\Extension\OATHAuth\Module;
|
|||
|
||||
use MediaWiki\Auth\SecondaryAuthenticationProvider;
|
||||
use MediaWiki\Extension\OATHAuth\HTMLForm\IManageForm;
|
||||
use MediaWiki\Extension\OATHAuth\HTMLForm\TOTPDisableForm;
|
||||
use MediaWiki\Extension\OATHAuth\IAuthKey;
|
||||
use MediaWiki\Extension\OATHAuth\IModule;
|
||||
use MediaWiki\Extension\OATHAuth\Key\TOTPKey;
|
||||
|
@ -12,7 +13,6 @@ use MediaWiki\Extension\OATHAuth\OATHUserRepository;
|
|||
use MediaWiki\Extension\OATHAuth\Special\OATHManage;
|
||||
use MWException;
|
||||
use MediaWiki\Extension\OATHAuth\HTMLForm\TOTPEnableForm;
|
||||
use MediaWiki\Extension\OATHAuth\HTMLForm\TOTPDisableForm;
|
||||
use MediaWiki\Extension\OATHAuth\Auth\TOTPSecondaryAuthenticationProvider;
|
||||
|
||||
class TOTP implements IModule {
|
||||
|
@ -107,14 +107,14 @@ class TOTP implements IModule {
|
|||
* @return IManageForm|null
|
||||
*/
|
||||
public function getManageForm( $action, OATHUser $user, OATHUserRepository $repo ) {
|
||||
switch ( $action ) {
|
||||
case OATHManage::ACTION_ENABLE:
|
||||
$isEnabledForUser = $user->getModule() instanceof self;
|
||||
if ( $action === OATHManage::ACTION_ENABLE && !$isEnabledForUser ) {
|
||||
return new TOTPEnableForm( $user, $repo, $this );
|
||||
case OATHManage::ACTION_DISABLE:
|
||||
return new TOTPDisableForm( $user, $repo, $this );
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
if ( $action === OATHManage::ACTION_DISABLE && $isEnabledForUser ) {
|
||||
return new TOTPDisableForm( $user, $repo, $this );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue