Application.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\TwoFactorBackupCodes\AppInfo;
  27. use OCA\TwoFactorBackupCodes\Event\CodesGenerated;
  28. use OCA\TwoFactorBackupCodes\Listener\ActivityPublisher;
  29. use OCA\TwoFactorBackupCodes\Listener\ClearNotifications;
  30. use OCA\TwoFactorBackupCodes\Listener\ProviderDisabled;
  31. use OCA\TwoFactorBackupCodes\Listener\ProviderEnabled;
  32. use OCA\TwoFactorBackupCodes\Listener\RegistryUpdater;
  33. use OCA\TwoFactorBackupCodes\Listener\UserDeleted;
  34. use OCA\TwoFactorBackupCodes\Notifications\Notifier;
  35. use OCA\TwoFactorBackupCodes\Provider\BackupCodesProvider;
  36. use OCP\AppFramework\App;
  37. use OCP\AppFramework\Bootstrap\IBootContext;
  38. use OCP\AppFramework\Bootstrap\IBootstrap;
  39. use OCP\AppFramework\Bootstrap\IRegistrationContext;
  40. use OCP\Authentication\TwoFactorAuth\TwoFactorProviderForUserRegistered;
  41. use OCP\Authentication\TwoFactorAuth\TwoFactorProviderForUserUnregistered;
  42. use OCP\User\Events\UserDeletedEvent;
  43. class Application extends App implements IBootstrap {
  44. public const APP_ID = 'twofactor_backupcodes';
  45. public function __construct() {
  46. parent::__construct(self::APP_ID);
  47. }
  48. public function register(IRegistrationContext $context): void {
  49. $context->registerNotifierService(Notifier::class);
  50. $context->registerEventListener(CodesGenerated::class, ActivityPublisher::class);
  51. $context->registerEventListener(CodesGenerated::class, RegistryUpdater::class);
  52. $context->registerEventListener(CodesGenerated::class, ClearNotifications::class);
  53. $context->registerEventListener(TwoFactorProviderForUserRegistered::class, ProviderEnabled::class);
  54. $context->registerEventListener(TwoFactorProviderForUserUnregistered::class, ProviderDisabled::class);
  55. $context->registerEventListener(UserDeletedEvent::class, UserDeleted::class);
  56. $context->registerTwoFactorProvider(BackupCodesProvider::class);
  57. }
  58. public function boot(IBootContext $context): void {
  59. }
  60. }