use OCP\IUser;
use OCP\Session\Exceptions\SessionNotAvailableException;
use Psr\Log\LoggerInterface;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
use function array_diff;
use function array_filter;
/** @var IEventDispatcher */
private $dispatcher;
- /** @var EventDispatcherInterface */
- private $legacyDispatcher;
-
/** @psalm-var array<string, bool> */
private $userIsTwoFactorAuthenticated = [];
LoggerInterface $logger,
TokenProvider $tokenProvider,
ITimeFactory $timeFactory,
- IEventDispatcher $eventDispatcher,
- EventDispatcherInterface $legacyDispatcher) {
+ IEventDispatcher $eventDispatcher) {
$this->providerLoader = $providerLoader;
$this->providerRegistry = $providerRegistry;
$this->mandatoryTwoFactor = $mandatoryTwoFactor;
$this->tokenProvider = $tokenProvider;
$this->timeFactory = $timeFactory;
$this->dispatcher = $eventDispatcher;
- $this->legacyDispatcher = $legacyDispatcher;
}
/**
$tokenId = $token->getId();
$this->config->deleteUserValue($user->getUID(), 'login_token_2fa', (string)$tokenId);
- $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
- $this->legacyDispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent);
-
$this->dispatcher->dispatchTyped(new TwoFactorProviderForUserEnabled($user, $provider));
$this->dispatcher->dispatchTyped(new TwoFactorProviderChallengePassed($user, $provider));
'provider' => $provider->getDisplayName(),
]);
} else {
- $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
- $this->legacyDispatcher->dispatch(IProvider::EVENT_FAILED, $dispatchEvent);
-
$this->dispatcher->dispatchTyped(new TwoFactorProviderForUserDisabled($user, $provider));
$this->dispatcher->dispatchTyped(new TwoFactorProviderChallengeFailed($user, $provider));
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use function reset;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;
class ManagerTest extends TestCase {
private $timeFactory;
/** @var IEventDispatcher|MockObject */
- private $newDispatcher;
-
- /** @var EventDispatcherInterface|MockObject */
- private $eventDispatcher;
+ private $dispatcher;
protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(LoggerInterface::class);
$this->tokenProvider = $this->createMock(TokenProvider::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
- $this->newDispatcher = $this->createMock(IEventDispatcher::class);
- $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
+ $this->dispatcher = $this->createMock(IEventDispatcher::class);
$this->manager = new Manager(
$this->providerLoader,
$this->logger,
$this->tokenProvider,
$this->timeFactory,
- $this->newDispatcher,
- $this->eventDispatcher
+ $this->dispatcher,
);
$this->fakeProvider = $this->createMock(IProvider::class);
$this->logger,
$this->tokenProvider,
$this->timeFactory,
- $this->newDispatcher,
- $this->eventDispatcher
+ $this->dispatcher,
])
->setMethods(['loadTwoFactorApp', 'isTwoFactorAuthenticated'])// Do not actually load the apps
->getMock();