diff options
author | Vitor Mattos <vitor@php.rio> | 2022-05-09 18:24:57 +0300 |
---|---|---|
committer | Vitor Mattos <vitor@php.rio> | 2022-05-09 18:24:57 +0300 |
commit | b0bc0bec276daf26a4710ecc0d3b204ab7d45ca0 (patch) | |
tree | d453561f94a0d5eff759761dd4d006a644be9105 | |
parent | 844902e8d646b3f3cf5f6b4c8ab4a51d02c200f1 (diff) |
Make possible use the commad twofactorauth:disablefeature/disable-provider
Signed-off-by: Vitor Mattos <vitor@php.rio>
-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)); + } + } } |