diff options
-rw-r--r-- | lib/Provider/AProvider.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Provider/AProvider.php b/lib/Provider/AProvider.php index f2a7f41..6f551cc 100644 --- a/lib/Provider/AProvider.php +++ b/lib/Provider/AProvider.php @@ -29,6 +29,7 @@ use OCA\TwoFactorGateway\PhoneNumberMask; use OCA\TwoFactorGateway\Service\Gateway\IGateway; use OCA\TwoFactorGateway\Service\StateStorage; use OCA\TwoFactorGateway\Settings\PersonalSettings; +use OCP\Authentication\TwoFactorAuth\IDeactivatableByAdmin; use OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings; use OCP\Authentication\TwoFactorAuth\IProvider; use OCP\Authentication\TwoFactorAuth\IProvidesIcons; @@ -39,7 +40,7 @@ use OCP\IUser; use OCP\Security\ISecureRandom; use OCP\Template; -abstract class AProvider implements IProvider, IProvidesIcons, IProvidesPersonalSettings { +abstract class AProvider implements IProvider, IProvidesIcons, IDeactivatableByAdmin, IProvidesPersonalSettings { public const STATE_DISABLED = 0; public const STATE_START_VERIFICATION = 1; public const STATE_VERIFYING = 2; @@ -155,4 +156,11 @@ abstract class AProvider implements IProvider, IProvidesIcons, IProvidesPersonal public function getDarkIcon(): String { return image_path(Application::APP_ID, 'app-dark.svg'); } + + public function disableFor(IUser $user) { + $state = $this->stateStorage->get($user, $this->gatewayName); + if ($state->getState() === self::STATE_ENABLED) { + $this->stateStorage->persist($state->disabled($user, $this->gatewayName)); + } + } } |