diff options
author | kesselb <mail@danielkesselberg.de> | 2021-03-30 23:13:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 23:13:36 +0200 |
commit | 2212a67fbca5b61b69728f34fdc09d0bd0b22036 (patch) | |
tree | 12ec83d243e2ebbf670de6c18860e51ba25ea852 /lib/private | |
parent | f3738eeff70ead6657149fa5d25bfde04f731746 (diff) | |
parent | 3c5cf825b396eacdc3e2376137e010552796119e (diff) | |
download | nextcloud-server-2212a67fbca5b61b69728f34fdc09d0bd0b22036.tar.gz nextcloud-server-2212a67fbca5b61b69728f34fdc09d0bd0b22036.zip |
Merge pull request #25961 from nextcloud/enh/events/2fa_provider
Add real events for enabled 2fa providers for users
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Authentication/TwoFactorAuth/Manager.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/private/Authentication/TwoFactorAuth/Manager.php b/lib/private/Authentication/TwoFactorAuth/Manager.php index d95cc8b1ebf..4391f7d108e 100644 --- a/lib/private/Authentication/TwoFactorAuth/Manager.php +++ b/lib/private/Authentication/TwoFactorAuth/Manager.php @@ -37,6 +37,9 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\Authentication\TwoFactorAuth\IActivatableAtLogin; use OCP\Authentication\TwoFactorAuth\IProvider; use OCP\Authentication\TwoFactorAuth\IRegistry; +use OCP\Authentication\TwoFactorAuth\TwoFactorProviderForUserDisabled; +use OCP\Authentication\TwoFactorAuth\TwoFactorProviderForUserEnabled; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\ISession; use OCP\IUser; @@ -79,9 +82,12 @@ class Manager { /** @var ITimeFactory */ private $timeFactory; - /** @var EventDispatcherInterface */ + /** @var IEventDispatcher */ private $dispatcher; + /** @var EventDispatcherInterface */ + private $legacyDispatcher; + public function __construct(ProviderLoader $providerLoader, IRegistry $providerRegistry, MandatoryTwoFactor $mandatoryTwoFactor, @@ -91,7 +97,8 @@ class Manager { LoggerInterface $logger, TokenProvider $tokenProvider, ITimeFactory $timeFactory, - EventDispatcherInterface $eventDispatcher) { + IEventDispatcher $eventDispatcher, + EventDispatcherInterface $legacyDispatcher) { $this->providerLoader = $providerLoader; $this->providerRegistry = $providerRegistry; $this->mandatoryTwoFactor = $mandatoryTwoFactor; @@ -102,6 +109,7 @@ class Manager { $this->tokenProvider = $tokenProvider; $this->timeFactory = $timeFactory; $this->dispatcher = $eventDispatcher; + $this->legacyDispatcher = $legacyDispatcher; } /** @@ -267,14 +275,18 @@ class Manager { $this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $tokenId); $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]); - $this->dispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent); + $this->legacyDispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent); + + $this->dispatcher->dispatchTyped(new TwoFactorProviderForUserEnabled($user, $provider)); $this->publishEvent($user, 'twofactor_success', [ 'provider' => $provider->getDisplayName(), ]); } else { $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]); - $this->dispatcher->dispatch(IProvider::EVENT_FAILED, $dispatchEvent); + $this->legacyDispatcher->dispatch(IProvider::EVENT_FAILED, $dispatchEvent); + + $this->dispatcher->dispatchTyped(new TwoFactorProviderForUserDisabled($user, $provider)); $this->publishEvent($user, 'twofactor_failed', [ 'provider' => $provider->getDisplayName(), |