Application.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\TwoFactorBackupCodes\AppInfo;
  8. use OCA\TwoFactorBackupCodes\Event\CodesGenerated;
  9. use OCA\TwoFactorBackupCodes\Listener\ActivityPublisher;
  10. use OCA\TwoFactorBackupCodes\Listener\ClearNotifications;
  11. use OCA\TwoFactorBackupCodes\Listener\ProviderDisabled;
  12. use OCA\TwoFactorBackupCodes\Listener\ProviderEnabled;
  13. use OCA\TwoFactorBackupCodes\Listener\RegistryUpdater;
  14. use OCA\TwoFactorBackupCodes\Listener\UserDeleted;
  15. use OCA\TwoFactorBackupCodes\Notifications\Notifier;
  16. use OCA\TwoFactorBackupCodes\Provider\BackupCodesProvider;
  17. use OCP\AppFramework\App;
  18. use OCP\AppFramework\Bootstrap\IBootContext;
  19. use OCP\AppFramework\Bootstrap\IBootstrap;
  20. use OCP\AppFramework\Bootstrap\IRegistrationContext;
  21. use OCP\Authentication\TwoFactorAuth\TwoFactorProviderForUserRegistered;
  22. use OCP\Authentication\TwoFactorAuth\TwoFactorProviderForUserUnregistered;
  23. use OCP\User\Events\UserDeletedEvent;
  24. class Application extends App implements IBootstrap {
  25. public const APP_ID = 'twofactor_backupcodes';
  26. public function __construct() {
  27. parent::__construct(self::APP_ID);
  28. }
  29. public function register(IRegistrationContext $context): void {
  30. $context->registerNotifierService(Notifier::class);
  31. $context->registerEventListener(CodesGenerated::class, ActivityPublisher::class);
  32. $context->registerEventListener(CodesGenerated::class, RegistryUpdater::class);
  33. $context->registerEventListener(CodesGenerated::class, ClearNotifications::class);
  34. $context->registerEventListener(TwoFactorProviderForUserRegistered::class, ProviderEnabled::class);
  35. $context->registerEventListener(TwoFactorProviderForUserUnregistered::class, ProviderDisabled::class);
  36. $context->registerEventListener(UserDeletedEvent::class, UserDeleted::class);
  37. $context->registerTwoFactorProvider(BackupCodesProvider::class);
  38. }
  39. public function boot(IBootContext $context): void {
  40. }
  41. }