Replace more users of getModule() for enabled checks

Bug: T242031
Change-Id: I602b5c0cf36096a7fc41116874e776277bf6f833
This commit is contained in:
Taavi Väänänen 2023-11-23 20:55:01 +02:00
parent 4fee32d2f3
commit 1df74c2e2b
No known key found for this signature in database
GPG key ID: EF242F709F912FBE
2 changed files with 5 additions and 11 deletions

View file

@ -101,7 +101,7 @@ class HookHandler implements
// If there is no existing module for the user, and the user is not allowed to enable it,
// we have nothing to show.
if (
$oathUser->getModule() === null &&
!$oathUser->isTwoFactorAuthEnabled() &&
!$this->permissionManager->userHasRight( $user, 'oathauth-enable' )
) {
return true;
@ -182,7 +182,7 @@ class HookHandler implements
}
$oathUser = $this->userRepo->findByUser( $user );
if ( $oathUser->getModule() === null ) {
if ( !$oathUser->isTwoFactorAuthEnabled() ) {
// Not enabled, strip the groups
return $intersect;
}

View file

@ -6,7 +6,6 @@ use ConfigException;
use FormSpecialPage;
use HTMLForm;
use ManualLogEntry;
use MediaWiki\Extension\OATHAuth\IModule;
use MediaWiki\Extension\OATHAuth\OATHUserRepository;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\User\UserFactory;
@ -119,14 +118,9 @@ class VerifyOATHForUser extends FormSpecialPage {
}
$oathUser = $this->userRepo->findByUser( $user );
if ( !( $oathUser->getModule() instanceof IModule ) ||
!$oathUser->getModule()->isEnabled( $oathUser ) ) {
$result = self::OATHAUTH_NOT_ENABLED;
} else {
$result = self::OATHAUTH_IS_ENABLED;
}
$this->enabledStatus = $result;
$this->enabledStatus = $oathUser->isTwoFactorAuthEnabled()
? self::OATHAUTH_IS_ENABLED
: self::OATHAUTH_NOT_ENABLED;
// message used: logentry-oath-verify
$logEntry = new ManualLogEntry( 'oath', 'verify' );