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

github.com/nextcloud/twofactor_totp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-01-22 16:59:19 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-01-22 18:57:45 +0300
commit93cdcbb8ca812fee521692f972bb29f9a0d543d3 (patch)
tree8840da9936baaf4a4a2bc3239e0cc0855bc31d6f /lib
parent78375a092490979623d18062519234fcf144c13a (diff)
Drop Nextcloud 20 support
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php28
-rw-r--r--lib/Provider/TotpProvider.php12
2 files changed, 23 insertions, 17 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 4b95d87..ff5f7f4 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -30,21 +30,27 @@ use OCA\TwoFactorTOTP\Listener\StateChangeRegistryUpdater;
use OCA\TwoFactorTOTP\Service\ITotp;
use OCA\TwoFactorTOTP\Service\Totp;
use OCP\AppFramework\App;
-use OCP\EventDispatcher\IEventDispatcher;
+use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\AppFramework\Bootstrap\IBootstrap;
+use OCP\AppFramework\Bootstrap\IRegistrationContext;
-class Application extends App {
+class Application extends App implements IBootstrap {
public const APP_ID = 'twofactor_totp';
- public function __construct(array $urlParams = []) {
- parent::__construct(self::APP_ID, $urlParams);
+ public function __construct() {
+ parent::__construct(self::APP_ID);
+ }
+
+ public function register(IRegistrationContext $context): void {
+ include_once __DIR__ . '/../../vendor/autoload.php';
- $container = $this->getContainer();
- $container->registerAlias(ITotp::class, Totp::class);
+ $context->registerServiceAlias(ITotp::class, Totp::class);
+
+ $context->registerEventListener(StateChanged::class, StateChangeActivity::class);
+ $context->registerEventListener(StateChanged::class, StateChangeRegistryUpdater::class);
+ $context->registerEventListener(DisabledByAdmin::class, StateChangeActivity::class);
+ }
- /** @var IEventDispatcher $dispatcher */
- $dispatcher = $container->query(IEventDispatcher::class);
- $dispatcher->addServiceListener(StateChanged::class, StateChangeActivity::class);
- $dispatcher->addServiceListener(StateChanged::class, StateChangeRegistryUpdater::class);
- $dispatcher->addServiceListener(DisabledByAdmin::class, StateChangeActivity::class);
+ public function boot(IBootContext $context): void {
}
}
diff --git a/lib/Provider/TotpProvider.php b/lib/Provider/TotpProvider.php
index c3b78ac..210caae 100644
--- a/lib/Provider/TotpProvider.php
+++ b/lib/Provider/TotpProvider.php
@@ -27,6 +27,7 @@ use OCA\TwoFactorTOTP\AppInfo\Application;
use OCA\TwoFactorTOTP\Service\ITotp;
use OCA\TwoFactorTOTP\Settings\Personal;
use OCP\AppFramework\IAppContainer;
+use OCP\AppFramework\Services\IInitialState;
use OCP\Authentication\TwoFactorAuth\IActivatableAtLogin;
use OCP\Authentication\TwoFactorAuth\IDeactivatableByAdmin;
use OCP\Authentication\TwoFactorAuth\ILoginSetupProvider;
@@ -34,7 +35,6 @@ use OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings;
use OCP\Authentication\TwoFactorAuth\IProvider;
use OCP\Authentication\TwoFactorAuth\IProvidesIcons;
use OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings;
-use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
@@ -51,8 +51,8 @@ class TotpProvider implements IProvider, IProvidesIcons, IProvidesPersonalSettin
/** @var IAppContainer */
private $container;
- /** @var IInitialStateService */
- private $initialStateService;
+ /** @var IInitialState */
+ private $initialState;
/** @var IURLGenerator */
private $urlGenerator;
@@ -60,12 +60,12 @@ class TotpProvider implements IProvider, IProvidesIcons, IProvidesPersonalSettin
public function __construct(ITotp $totp,
IL10N $l10n,
IAppContainer $container,
- IInitialStateService $initialStateService,
+ IInitialState $initialStateService,
IURLGenerator $urlGenerator) {
$this->totp = $totp;
$this->l10n = $l10n;
$this->container = $container;
- $this->initialStateService = $initialStateService;
+ $this->initialState = $initialStateService;
$this->urlGenerator = $urlGenerator;
}
@@ -121,7 +121,7 @@ class TotpProvider implements IProvider, IProvidesIcons, IProvidesPersonalSettin
}
public function getPersonalSettings(IUser $user): IPersonalProviderSettings {
- $this->initialStateService->provideInitialState('twofactor_totp', 'state', $this->totp->hasSecret($user) ? ITotp::STATE_ENABLED : ITotp::STATE_DISABLED);
+ $this->initialState->provideInitialState('state', $this->totp->hasSecret($user) ? ITotp::STATE_ENABLED : ITotp::STATE_DISABLED);
return new Personal();
}