Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/twofactor_gateway.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2022-05-12 17:24:31 +0300
committerGitHub <noreply@github.com>2022-05-12 17:24:31 +0300
commit2e951f9433deed6e3b9a7e0fec192cfd5891a3af (patch)
treed453561f94a0d5eff759761dd4d006a644be9105
parent844902e8d646b3f3cf5f6b4c8ab4a51d02c200f1 (diff)
parentb0bc0bec276daf26a4710ecc0d3b204ab7d45ca0 (diff)
Merge pull request #510 from nextcloud/feature/disable-provider
Make possible use the commad twofactorauth:disable
-rw-r--r--lib/Provider/AProvider.php10
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));
+ }
+ }
}