diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-08-06 16:45:06 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-08-06 16:59:29 +0300 |
commit | 11e2821263d06a6ffc2aeb7e7b0d1a8d8c4e60ba (patch) | |
tree | e4604079affb379c1df6d594aa2ad4f97f88902c /lib/Service/SetupService.php | |
parent | 8896b8a0448224580bf5cff20c27cc8d38218d13 (diff) |
Fix state propagation for the provider registry
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Service/SetupService.php')
-rw-r--r-- | lib/Service/SetupService.php | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Service/SetupService.php b/lib/Service/SetupService.php index 9789a78..48a3473 100644 --- a/lib/Service/SetupService.php +++ b/lib/Service/SetupService.php @@ -25,11 +25,11 @@ declare(strict_types=1); namespace OCA\TwoFactorGateway\Service; use Exception; -use OCA\TwoFactorGateway\AppInfo\Application; use OCA\TwoFactorGateway\Exception\IdentifierMissingException; use OCA\TwoFactorGateway\Exception\SmsTransmissionException; use OCA\TwoFactorGateway\Exception\VerificationException; use OCA\TwoFactorGateway\Exception\VerificationTransmissionException; +use OCA\TwoFactorGateway\Provider\SmsProvider; use OCA\TwoFactorGateway\Provider\State; use OCP\Authentication\TwoFactorAuth\IRegistry; use OCP\IUser; @@ -46,12 +46,22 @@ class SetupService { /** @var ISecureRandom */ private $random; + /** @var SmsProvider */ + private $provider; + + /** @var IRegistry */ + private $providerRegistry; + public function __construct(StateStorage $stateStorage, IGateway $smsService, - ISecureRandom $random) { + ISecureRandom $random, + SmsProvider $provider, + IRegistry $providerRegistry) { $this->stateStorage = $stateStorage; $this->smsService = $smsService; $this->random = $random; + $this->provider = $provider; + $this->providerRegistry = $providerRegistry; } public function getState(IUser $user): State { @@ -97,12 +107,16 @@ class SetupService { throw new VerificationException('verification token mismatch'); } + $this->providerRegistry->enableProviderFor($this->provider, $user); + return $this->stateStorage->persist( $state->verify() ); } public function disable(IUser $user): State { + $this->providerRegistry->disableProviderFor($this->provider, $user); + return $this->stateStorage->persist( State::disabled($user) ); |