@@ -36,37 +36,37 @@ |
||
36 | 36 | |
37 | 37 | class Registry implements IRegistry { |
38 | 38 | |
39 | - /** @var ProviderUserAssignmentDao */ |
|
40 | - private $assignmentDao; |
|
39 | + /** @var ProviderUserAssignmentDao */ |
|
40 | + private $assignmentDao; |
|
41 | 41 | |
42 | - /** @var EventDispatcherInterface */ |
|
43 | - private $dispatcher; |
|
42 | + /** @var EventDispatcherInterface */ |
|
43 | + private $dispatcher; |
|
44 | 44 | |
45 | - public function __construct(ProviderUserAssignmentDao $assignmentDao, |
|
46 | - EventDispatcherInterface $dispatcher) { |
|
47 | - $this->assignmentDao = $assignmentDao; |
|
48 | - $this->dispatcher = $dispatcher; |
|
49 | - } |
|
45 | + public function __construct(ProviderUserAssignmentDao $assignmentDao, |
|
46 | + EventDispatcherInterface $dispatcher) { |
|
47 | + $this->assignmentDao = $assignmentDao; |
|
48 | + $this->dispatcher = $dispatcher; |
|
49 | + } |
|
50 | 50 | |
51 | - public function getProviderStates(IUser $user): array { |
|
52 | - return $this->assignmentDao->getState($user->getUID()); |
|
53 | - } |
|
51 | + public function getProviderStates(IUser $user): array { |
|
52 | + return $this->assignmentDao->getState($user->getUID()); |
|
53 | + } |
|
54 | 54 | |
55 | - public function enableProviderFor(IProvider $provider, IUser $user) { |
|
56 | - $this->assignmentDao->persist($provider->getId(), $user->getUID(), 1); |
|
55 | + public function enableProviderFor(IProvider $provider, IUser $user) { |
|
56 | + $this->assignmentDao->persist($provider->getId(), $user->getUID(), 1); |
|
57 | 57 | |
58 | - $event = new RegistryEvent($provider, $user); |
|
59 | - $this->dispatcher->dispatch(self::EVENT_PROVIDER_ENABLED, $event); |
|
60 | - } |
|
58 | + $event = new RegistryEvent($provider, $user); |
|
59 | + $this->dispatcher->dispatch(self::EVENT_PROVIDER_ENABLED, $event); |
|
60 | + } |
|
61 | 61 | |
62 | - public function disableProviderFor(IProvider $provider, IUser $user) { |
|
63 | - $this->assignmentDao->persist($provider->getId(), $user->getUID(), 0); |
|
62 | + public function disableProviderFor(IProvider $provider, IUser $user) { |
|
63 | + $this->assignmentDao->persist($provider->getId(), $user->getUID(), 0); |
|
64 | 64 | |
65 | - $event = new RegistryEvent($provider, $user); |
|
66 | - $this->dispatcher->dispatch(self::EVENT_PROVIDER_DISABLED, $event); |
|
67 | - } |
|
65 | + $event = new RegistryEvent($provider, $user); |
|
66 | + $this->dispatcher->dispatch(self::EVENT_PROVIDER_DISABLED, $event); |
|
67 | + } |
|
68 | 68 | |
69 | - public function cleanUp(string $providerId) { |
|
70 | - $this->assignmentDao->deleteAll($providerId); |
|
71 | - } |
|
69 | + public function cleanUp(string $providerId) { |
|
70 | + $this->assignmentDao->deleteAll($providerId); |
|
71 | + } |
|
72 | 72 | } |
@@ -40,45 +40,45 @@ |
||
40 | 40 | interface IRegistry { |
41 | 41 | |
42 | 42 | |
43 | - const EVENT_PROVIDER_ENABLED = self::class . '::enable'; |
|
44 | - const EVENT_PROVIDER_DISABLED = self::class . '::disable'; |
|
43 | + const EVENT_PROVIDER_ENABLED = self::class . '::enable'; |
|
44 | + const EVENT_PROVIDER_DISABLED = self::class . '::disable'; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get a key-value map of providers and their enabled/disabled state for |
|
48 | - * the given user. |
|
49 | - * |
|
50 | - * @since 14.0.0 |
|
51 | - * @return string[] where the array key is the provider ID (string) and the |
|
52 | - * value is the enabled state (bool) |
|
53 | - */ |
|
54 | - public function getProviderStates(IUser $user): array; |
|
46 | + /** |
|
47 | + * Get a key-value map of providers and their enabled/disabled state for |
|
48 | + * the given user. |
|
49 | + * |
|
50 | + * @since 14.0.0 |
|
51 | + * @return string[] where the array key is the provider ID (string) and the |
|
52 | + * value is the enabled state (bool) |
|
53 | + */ |
|
54 | + public function getProviderStates(IUser $user): array; |
|
55 | 55 | |
56 | - /** |
|
57 | - * Enable the given 2FA provider for the given user |
|
58 | - * |
|
59 | - * @since 14.0.0 |
|
60 | - */ |
|
61 | - public function enableProviderFor(IProvider $provider, IUser $user); |
|
56 | + /** |
|
57 | + * Enable the given 2FA provider for the given user |
|
58 | + * |
|
59 | + * @since 14.0.0 |
|
60 | + */ |
|
61 | + public function enableProviderFor(IProvider $provider, IUser $user); |
|
62 | 62 | |
63 | - /** |
|
64 | - * Disable the given 2FA provider for the given user |
|
65 | - * |
|
66 | - * @since 14.0.0 |
|
67 | - */ |
|
68 | - public function disableProviderFor(IProvider $provider, IUser $user); |
|
63 | + /** |
|
64 | + * Disable the given 2FA provider for the given user |
|
65 | + * |
|
66 | + * @since 14.0.0 |
|
67 | + */ |
|
68 | + public function disableProviderFor(IProvider $provider, IUser $user); |
|
69 | 69 | |
70 | - /** |
|
71 | - * Cleans up all entries of the provider with the given id. This is only |
|
72 | - * necessary in edge-cases where an admin disabled and/or uninstalled a |
|
73 | - * provider app. Invoking this method will make sure outdated provider |
|
74 | - * associations are removed so that users can log in. |
|
75 | - * |
|
76 | - * @since 15.0.0 |
|
77 | - * |
|
78 | - * @param string $providerId |
|
79 | - * |
|
80 | - * @return void |
|
81 | - */ |
|
82 | - public function cleanUp(string $providerId); |
|
70 | + /** |
|
71 | + * Cleans up all entries of the provider with the given id. This is only |
|
72 | + * necessary in edge-cases where an admin disabled and/or uninstalled a |
|
73 | + * provider app. Invoking this method will make sure outdated provider |
|
74 | + * associations are removed so that users can log in. |
|
75 | + * |
|
76 | + * @since 15.0.0 |
|
77 | + * |
|
78 | + * @param string $providerId |
|
79 | + * |
|
80 | + * @return void |
|
81 | + */ |
|
82 | + public function cleanUp(string $providerId); |
|
83 | 83 | |
84 | 84 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * @copyright 2018 Christoph Wurst <[email protected]> |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | interface IRegistry { |
41 | 41 | |
42 | 42 | |
43 | - const EVENT_PROVIDER_ENABLED = self::class . '::enable'; |
|
44 | - const EVENT_PROVIDER_DISABLED = self::class . '::disable'; |
|
43 | + const EVENT_PROVIDER_ENABLED = self::class.'::enable'; |
|
44 | + const EVENT_PROVIDER_DISABLED = self::class.'::disable'; |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Get a key-value map of providers and their enabled/disabled state for |
@@ -32,31 +32,31 @@ |
||
32 | 32 | */ |
33 | 33 | class RegistryEvent extends Event { |
34 | 34 | |
35 | - /** @var IProvider */ |
|
36 | - private $provider; |
|
37 | - |
|
38 | - /** @IUser */ |
|
39 | - private $user; |
|
40 | - |
|
41 | - /** |
|
42 | - * @since 15.0.0 |
|
43 | - */ |
|
44 | - public function __construct(IProvider $provider, IUser $user) { |
|
45 | - $this->provider = $provider; |
|
46 | - $this->user = $user; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @since 15.0.0 |
|
51 | - */ |
|
52 | - public function getProvider(): IProvider { |
|
53 | - return $this->provider; |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @since 15.0.0 |
|
58 | - */ |
|
59 | - public function getUser(): IUser { |
|
60 | - return $this->user; |
|
61 | - } |
|
35 | + /** @var IProvider */ |
|
36 | + private $provider; |
|
37 | + |
|
38 | + /** @IUser */ |
|
39 | + private $user; |
|
40 | + |
|
41 | + /** |
|
42 | + * @since 15.0.0 |
|
43 | + */ |
|
44 | + public function __construct(IProvider $provider, IUser $user) { |
|
45 | + $this->provider = $provider; |
|
46 | + $this->user = $user; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @since 15.0.0 |
|
51 | + */ |
|
52 | + public function getProvider(): IProvider { |
|
53 | + return $this->provider; |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @since 15.0.0 |
|
58 | + */ |
|
59 | + public function getUser(): IUser { |
|
60 | + return $this->user; |
|
61 | + } |
|
62 | 62 | } |
@@ -30,22 +30,22 @@ |
||
30 | 30 | |
31 | 31 | class ClearNotifications implements IListener { |
32 | 32 | |
33 | - /** @var IManager */ |
|
34 | - private $manager; |
|
33 | + /** @var IManager */ |
|
34 | + private $manager; |
|
35 | 35 | |
36 | - public function __construct(IManager $manager) { |
|
37 | - $this->manager = $manager; |
|
38 | - } |
|
36 | + public function __construct(IManager $manager) { |
|
37 | + $this->manager = $manager; |
|
38 | + } |
|
39 | 39 | |
40 | - public function handle(Event $event) { |
|
41 | - if (!($event instanceof CodesGenerated)) { |
|
42 | - return; |
|
43 | - } |
|
40 | + public function handle(Event $event) { |
|
41 | + if (!($event instanceof CodesGenerated)) { |
|
42 | + return; |
|
43 | + } |
|
44 | 44 | |
45 | - $notification = $this->manager->createNotification(); |
|
46 | - $notification->setApp('twofactor_backupcodes') |
|
47 | - ->setUser($event->getUser()->getUID()) |
|
48 | - ->setObject('create', 'codes'); |
|
49 | - $this->manager->markProcessed($notification); |
|
50 | - } |
|
45 | + $notification = $this->manager->createNotification(); |
|
46 | + $notification->setApp('twofactor_backupcodes') |
|
47 | + ->setUser($event->getUser()->getUID()) |
|
48 | + ->setObject('create', 'codes'); |
|
49 | + $this->manager->markProcessed($notification); |
|
50 | + } |
|
51 | 51 | } |
@@ -32,30 +32,30 @@ |
||
32 | 32 | |
33 | 33 | class ProviderEnabled implements IListener { |
34 | 34 | |
35 | - /** @var IRegistry */ |
|
36 | - private $registry; |
|
37 | - |
|
38 | - /** @var IJobList */ |
|
39 | - private $jobList; |
|
40 | - |
|
41 | - public function __construct(IRegistry $registry, |
|
42 | - IJobList $jobList) { |
|
43 | - $this->registry = $registry; |
|
44 | - $this->jobList = $jobList; |
|
45 | - } |
|
46 | - |
|
47 | - public function handle(Event $event) { |
|
48 | - if (!($event instanceof RegistryEvent)) { |
|
49 | - return; |
|
50 | - } |
|
51 | - |
|
52 | - $providers = $this->registry->getProviderStates($event->getUser()); |
|
53 | - if (isset($providers['backup_codes']) && $providers['backup_codes'] === true) { |
|
54 | - // Backup codes already generated nothing to do here |
|
55 | - return; |
|
56 | - } |
|
57 | - |
|
58 | - $this->jobList->add(RememberBackupCodesJob::class, ['uid' => $event->getUser()->getUID()]); |
|
59 | - } |
|
35 | + /** @var IRegistry */ |
|
36 | + private $registry; |
|
37 | + |
|
38 | + /** @var IJobList */ |
|
39 | + private $jobList; |
|
40 | + |
|
41 | + public function __construct(IRegistry $registry, |
|
42 | + IJobList $jobList) { |
|
43 | + $this->registry = $registry; |
|
44 | + $this->jobList = $jobList; |
|
45 | + } |
|
46 | + |
|
47 | + public function handle(Event $event) { |
|
48 | + if (!($event instanceof RegistryEvent)) { |
|
49 | + return; |
|
50 | + } |
|
51 | + |
|
52 | + $providers = $this->registry->getProviderStates($event->getUser()); |
|
53 | + if (isset($providers['backup_codes']) && $providers['backup_codes'] === true) { |
|
54 | + // Backup codes already generated nothing to do here |
|
55 | + return; |
|
56 | + } |
|
57 | + |
|
58 | + $this->jobList->add(RememberBackupCodesJob::class, ['uid' => $event->getUser()->getUID()]); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
@@ -33,60 +33,60 @@ |
||
33 | 33 | |
34 | 34 | class RememberBackupCodesJob extends TimedJob { |
35 | 35 | |
36 | - /** @var IRegistry */ |
|
37 | - private $registry; |
|
36 | + /** @var IRegistry */ |
|
37 | + private $registry; |
|
38 | 38 | |
39 | - /** @var IUserManager */ |
|
40 | - private $userManager; |
|
39 | + /** @var IUserManager */ |
|
40 | + private $userManager; |
|
41 | 41 | |
42 | - /** @var ITimeFactory */ |
|
43 | - private $time; |
|
42 | + /** @var ITimeFactory */ |
|
43 | + private $time; |
|
44 | 44 | |
45 | - /** @var IManager */ |
|
46 | - private $notificationManager; |
|
45 | + /** @var IManager */ |
|
46 | + private $notificationManager; |
|
47 | 47 | |
48 | - /** @var IJobList */ |
|
49 | - private $jobList; |
|
48 | + /** @var IJobList */ |
|
49 | + private $jobList; |
|
50 | 50 | |
51 | - public function __construct(IRegistry $registry, |
|
52 | - IUserManager $userManager, |
|
53 | - ITimeFactory $timeFactory, |
|
54 | - IManager $notificationManager, |
|
55 | - IJobList $jobList) { |
|
56 | - $this->registry = $registry; |
|
57 | - $this->userManager = $userManager; |
|
58 | - $this->time = $timeFactory; |
|
59 | - $this->notificationManager = $notificationManager; |
|
60 | - $this->jobList = $jobList; |
|
51 | + public function __construct(IRegistry $registry, |
|
52 | + IUserManager $userManager, |
|
53 | + ITimeFactory $timeFactory, |
|
54 | + IManager $notificationManager, |
|
55 | + IJobList $jobList) { |
|
56 | + $this->registry = $registry; |
|
57 | + $this->userManager = $userManager; |
|
58 | + $this->time = $timeFactory; |
|
59 | + $this->notificationManager = $notificationManager; |
|
60 | + $this->jobList = $jobList; |
|
61 | 61 | |
62 | - $this->setInterval(60*60*24*14); |
|
63 | - } |
|
62 | + $this->setInterval(60*60*24*14); |
|
63 | + } |
|
64 | 64 | |
65 | - protected function run($argument) { |
|
66 | - $uid = $argument['uid']; |
|
67 | - $user = $this->userManager->get($uid); |
|
65 | + protected function run($argument) { |
|
66 | + $uid = $argument['uid']; |
|
67 | + $user = $this->userManager->get($uid); |
|
68 | 68 | |
69 | - if ($user === null) { |
|
70 | - // We can't run with an invalid user |
|
71 | - return; |
|
72 | - } |
|
69 | + if ($user === null) { |
|
70 | + // We can't run with an invalid user |
|
71 | + return; |
|
72 | + } |
|
73 | 73 | |
74 | - $providers = $this->registry->getProviderStates($user); |
|
75 | - if (isset($providers['backup_codes']) && $providers['backup_codes'] === true) { |
|
76 | - // Backup codes already generated lets remove this job |
|
77 | - $this->jobList->remove(self::class, $argument); |
|
78 | - return; |
|
79 | - } |
|
74 | + $providers = $this->registry->getProviderStates($user); |
|
75 | + if (isset($providers['backup_codes']) && $providers['backup_codes'] === true) { |
|
76 | + // Backup codes already generated lets remove this job |
|
77 | + $this->jobList->remove(self::class, $argument); |
|
78 | + return; |
|
79 | + } |
|
80 | 80 | |
81 | - $date = new \DateTime(); |
|
82 | - $date->setTimestamp($this->time->getTime()); |
|
81 | + $date = new \DateTime(); |
|
82 | + $date->setTimestamp($this->time->getTime()); |
|
83 | 83 | |
84 | - $notification = $this->notificationManager->createNotification(); |
|
85 | - $notification->setApp('twofactor_backupcodes') |
|
86 | - ->setUser($user->getUID()) |
|
87 | - ->setDateTime($date) |
|
88 | - ->setObject('create', 'codes') |
|
89 | - ->setSubject('create_backupcodes'); |
|
90 | - $this->notificationManager->notify($notification); |
|
91 | - } |
|
84 | + $notification = $this->notificationManager->createNotification(); |
|
85 | + $notification->setApp('twofactor_backupcodes') |
|
86 | + ->setUser($user->getUID()) |
|
87 | + ->setDateTime($date) |
|
88 | + ->setObject('create', 'codes') |
|
89 | + ->setSubject('create_backupcodes'); |
|
90 | + $this->notificationManager->notify($notification); |
|
91 | + } |
|
92 | 92 | } |
@@ -59,7 +59,7 @@ |
||
59 | 59 | $this->notificationManager = $notificationManager; |
60 | 60 | $this->jobList = $jobList; |
61 | 61 | |
62 | - $this->setInterval(60*60*24*14); |
|
62 | + $this->setInterval(60 * 60 * 24 * 14); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | protected function run($argument) { |
@@ -30,35 +30,35 @@ |
||
30 | 30 | |
31 | 31 | class Notifier implements INotifier { |
32 | 32 | |
33 | - /** @var IFactory */ |
|
34 | - private $factory; |
|
33 | + /** @var IFactory */ |
|
34 | + private $factory; |
|
35 | 35 | |
36 | - public function __construct(IFactory $factory) { |
|
37 | - $this->factory = $factory; |
|
38 | - } |
|
36 | + public function __construct(IFactory $factory) { |
|
37 | + $this->factory = $factory; |
|
38 | + } |
|
39 | 39 | |
40 | - public function prepare(INotification $notification, $languageCode) { |
|
41 | - if ($notification->getApp() !== 'twofactor_backupcodes') { |
|
42 | - // Not my app => throw |
|
43 | - throw new \InvalidArgumentException(); |
|
44 | - } |
|
40 | + public function prepare(INotification $notification, $languageCode) { |
|
41 | + if ($notification->getApp() !== 'twofactor_backupcodes') { |
|
42 | + // Not my app => throw |
|
43 | + throw new \InvalidArgumentException(); |
|
44 | + } |
|
45 | 45 | |
46 | - // Read the language from the notification |
|
47 | - $l = $this->factory->get('twofactor_backupcodes', $languageCode); |
|
46 | + // Read the language from the notification |
|
47 | + $l = $this->factory->get('twofactor_backupcodes', $languageCode); |
|
48 | 48 | |
49 | - switch ($notification->getSubject()) { |
|
50 | - case 'create_backupcodes': |
|
51 | - $notification->setParsedSubject( |
|
52 | - $l->t('Generate backup codes') |
|
53 | - )->setParsedMessage( |
|
54 | - $l->t('You have enabled two-factor authentication but have not yet generated backup codes. Be sure to do this in case you lose access to your second factor.') |
|
55 | - ); |
|
56 | - return $notification; |
|
49 | + switch ($notification->getSubject()) { |
|
50 | + case 'create_backupcodes': |
|
51 | + $notification->setParsedSubject( |
|
52 | + $l->t('Generate backup codes') |
|
53 | + )->setParsedMessage( |
|
54 | + $l->t('You have enabled two-factor authentication but have not yet generated backup codes. Be sure to do this in case you lose access to your second factor.') |
|
55 | + ); |
|
56 | + return $notification; |
|
57 | 57 | |
58 | - default: |
|
59 | - // Unknown subject => Unknown notification => throw |
|
60 | - throw new \InvalidArgumentException(); |
|
61 | - } |
|
62 | - } |
|
58 | + default: |
|
59 | + // Unknown subject => Unknown notification => throw |
|
60 | + throw new \InvalidArgumentException(); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | 64 | } |
@@ -42,65 +42,65 @@ |
||
42 | 42 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
43 | 43 | |
44 | 44 | class Application extends App { |
45 | - public function __construct() { |
|
46 | - parent::__construct('twofactor_backupcodes'); |
|
47 | - } |
|
45 | + public function __construct() { |
|
46 | + parent::__construct('twofactor_backupcodes'); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Register the different app parts |
|
51 | - */ |
|
52 | - public function register() { |
|
53 | - $this->registerHooksAndEvents(); |
|
54 | - $this->registerNotification(); |
|
55 | - } |
|
49 | + /** |
|
50 | + * Register the different app parts |
|
51 | + */ |
|
52 | + public function register() { |
|
53 | + $this->registerHooksAndEvents(); |
|
54 | + $this->registerNotification(); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Register the hooks and events |
|
59 | - */ |
|
60 | - public function registerHooksAndEvents() { |
|
61 | - Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser'); |
|
57 | + /** |
|
58 | + * Register the hooks and events |
|
59 | + */ |
|
60 | + public function registerHooksAndEvents() { |
|
61 | + Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser'); |
|
62 | 62 | |
63 | - $container = $this->getContainer(); |
|
64 | - /** @var EventDispatcherInterface $eventDispatcher */ |
|
65 | - $eventDispatcher = $container->query(EventDispatcherInterface::class); |
|
66 | - $eventDispatcher->addListener(CodesGenerated::class, function (CodesGenerated $event) use ($container) { |
|
67 | - /** @var IListener[] $listeners */ |
|
68 | - $listeners = [ |
|
69 | - $container->query(ActivityPublisher::class), |
|
70 | - $container->query(RegistryUpdater::class), |
|
71 | - $container->query(ClearNotifications::class), |
|
72 | - ]; |
|
63 | + $container = $this->getContainer(); |
|
64 | + /** @var EventDispatcherInterface $eventDispatcher */ |
|
65 | + $eventDispatcher = $container->query(EventDispatcherInterface::class); |
|
66 | + $eventDispatcher->addListener(CodesGenerated::class, function (CodesGenerated $event) use ($container) { |
|
67 | + /** @var IListener[] $listeners */ |
|
68 | + $listeners = [ |
|
69 | + $container->query(ActivityPublisher::class), |
|
70 | + $container->query(RegistryUpdater::class), |
|
71 | + $container->query(ClearNotifications::class), |
|
72 | + ]; |
|
73 | 73 | |
74 | - foreach ($listeners as $listener) { |
|
75 | - $listener->handle($event); |
|
76 | - } |
|
77 | - }); |
|
74 | + foreach ($listeners as $listener) { |
|
75 | + $listener->handle($event); |
|
76 | + } |
|
77 | + }); |
|
78 | 78 | |
79 | - $eventDispatcher->addListener(IRegistry::EVENT_PROVIDER_ENABLED, function(RegistryEvent $event) use ($container) { |
|
80 | - /** @var IListener $listener */ |
|
81 | - $listener = $container->query(ProviderEnabled::class); |
|
82 | - $listener->handle($event); |
|
83 | - }); |
|
84 | - } |
|
79 | + $eventDispatcher->addListener(IRegistry::EVENT_PROVIDER_ENABLED, function(RegistryEvent $event) use ($container) { |
|
80 | + /** @var IListener $listener */ |
|
81 | + $listener = $container->query(ProviderEnabled::class); |
|
82 | + $listener->handle($event); |
|
83 | + }); |
|
84 | + } |
|
85 | 85 | |
86 | - public function registerNotification() { |
|
87 | - $container = $this->getContainer(); |
|
88 | - /** @var IManager $manager */ |
|
89 | - $manager = $container->query(IManager::class); |
|
90 | - $manager->registerNotifier( |
|
91 | - function() use ($container) { |
|
92 | - return $container->query(Notifier::class); |
|
93 | - }, |
|
94 | - function () use ($container) { |
|
95 | - $l = $container->query(IL10N::class); |
|
96 | - return ['id' => 'twofactor_backupcodes', 'name' => $l->t('Second-factor backup codes')]; |
|
97 | - } |
|
98 | - ); |
|
99 | - } |
|
86 | + public function registerNotification() { |
|
87 | + $container = $this->getContainer(); |
|
88 | + /** @var IManager $manager */ |
|
89 | + $manager = $container->query(IManager::class); |
|
90 | + $manager->registerNotifier( |
|
91 | + function() use ($container) { |
|
92 | + return $container->query(Notifier::class); |
|
93 | + }, |
|
94 | + function () use ($container) { |
|
95 | + $l = $container->query(IL10N::class); |
|
96 | + return ['id' => 'twofactor_backupcodes', 'name' => $l->t('Second-factor backup codes')]; |
|
97 | + } |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | |
101 | - public function deleteUser($params) { |
|
102 | - /** @var BackupCodeMapper $mapper */ |
|
103 | - $mapper = $this->getContainer()->query(BackupCodeMapper::class); |
|
104 | - $mapper->deleteCodesByUserId($params['uid']); |
|
105 | - } |
|
101 | + public function deleteUser($params) { |
|
102 | + /** @var BackupCodeMapper $mapper */ |
|
103 | + $mapper = $this->getContainer()->query(BackupCodeMapper::class); |
|
104 | + $mapper->deleteCodesByUserId($params['uid']); |
|
105 | + } |
|
106 | 106 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $container = $this->getContainer(); |
64 | 64 | /** @var EventDispatcherInterface $eventDispatcher */ |
65 | 65 | $eventDispatcher = $container->query(EventDispatcherInterface::class); |
66 | - $eventDispatcher->addListener(CodesGenerated::class, function (CodesGenerated $event) use ($container) { |
|
66 | + $eventDispatcher->addListener(CodesGenerated::class, function(CodesGenerated $event) use ($container) { |
|
67 | 67 | /** @var IListener[] $listeners */ |
68 | 68 | $listeners = [ |
69 | 69 | $container->query(ActivityPublisher::class), |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | function() use ($container) { |
92 | 92 | return $container->query(Notifier::class); |
93 | 93 | }, |
94 | - function () use ($container) { |
|
94 | + function() use ($container) { |
|
95 | 95 | $l = $container->query(IL10N::class); |
96 | 96 | return ['id' => 'twofactor_backupcodes', 'name' => $l->t('Second-factor backup codes')]; |
97 | 97 | } |
@@ -6,47 +6,47 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInitTwoFactorBackupCodes |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'O' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'OCA\\TwoFactorBackupCodes\\' => 25, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'OCA\\TwoFactorBackupCodes\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/..'.'/../lib', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'OCA\\TwoFactorBackupCodes\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php', |
|
25 | - 'OCA\\TwoFactorBackupCodes\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
26 | - 'OCA\\TwoFactorBackupCodes\\BackgroundJob\\RememberBackupCodesJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/RememberBackupCodesJob.php', |
|
27 | - 'OCA\\TwoFactorBackupCodes\\Controller\\SettingsController' => __DIR__ . '/..' . '/../lib/Controller/SettingsController.php', |
|
28 | - 'OCA\\TwoFactorBackupCodes\\Db\\BackupCode' => __DIR__ . '/..' . '/../lib/Db/BackupCode.php', |
|
29 | - 'OCA\\TwoFactorBackupCodes\\Db\\BackupCodeMapper' => __DIR__ . '/..' . '/../lib/Db/BackupCodeMapper.php', |
|
30 | - 'OCA\\TwoFactorBackupCodes\\Event\\CodesGenerated' => __DIR__ . '/..' . '/../lib/Event/CodesGenerated.php', |
|
31 | - 'OCA\\TwoFactorBackupCodes\\Listener\\ActivityPublisher' => __DIR__ . '/..' . '/../lib/Listener/ActivityPublisher.php', |
|
32 | - 'OCA\\TwoFactorBackupCodes\\Listener\\ClearNotifications' => __DIR__ . '/..' . '/../lib/Listener/ClearNotifications.php', |
|
33 | - 'OCA\\TwoFactorBackupCodes\\Listener\\IListener' => __DIR__ . '/..' . '/../lib/Listener/IListener.php', |
|
34 | - 'OCA\\TwoFactorBackupCodes\\Listener\\ProviderEnabled' => __DIR__ . '/..' . '/../lib/Listener/ProviderEnabled.php', |
|
35 | - 'OCA\\TwoFactorBackupCodes\\Listener\\RegistryUpdater' => __DIR__ . '/..' . '/../lib/Listener/RegistryUpdater.php', |
|
36 | - 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607104347' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170607104347.php', |
|
37 | - 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607113030' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170607113030.php', |
|
38 | - 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170919123342' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170919123342.php', |
|
39 | - 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170926101419' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170926101419.php', |
|
40 | - 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20180821043638' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20180821043638.php', |
|
41 | - 'OCA\\TwoFactorBackupCodes\\Notifications\\Notifier' => __DIR__ . '/..' . '/../lib/Notifications/Notifier.php', |
|
42 | - 'OCA\\TwoFactorBackupCodes\\Provider\\BackupCodesProvider' => __DIR__ . '/..' . '/../lib/Provider/BackupCodesProvider.php', |
|
43 | - 'OCA\\TwoFactorBackupCodes\\Service\\BackupCodeStorage' => __DIR__ . '/..' . '/../lib/Service/BackupCodeStorage.php', |
|
44 | - 'OCA\\TwoFactorBackupCodes\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'OCA\\TwoFactorBackupCodes\\Activity\\Provider' => __DIR__.'/..'.'/../lib/Activity/Provider.php', |
|
25 | + 'OCA\\TwoFactorBackupCodes\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
26 | + 'OCA\\TwoFactorBackupCodes\\BackgroundJob\\RememberBackupCodesJob' => __DIR__.'/..'.'/../lib/BackgroundJob/RememberBackupCodesJob.php', |
|
27 | + 'OCA\\TwoFactorBackupCodes\\Controller\\SettingsController' => __DIR__.'/..'.'/../lib/Controller/SettingsController.php', |
|
28 | + 'OCA\\TwoFactorBackupCodes\\Db\\BackupCode' => __DIR__.'/..'.'/../lib/Db/BackupCode.php', |
|
29 | + 'OCA\\TwoFactorBackupCodes\\Db\\BackupCodeMapper' => __DIR__.'/..'.'/../lib/Db/BackupCodeMapper.php', |
|
30 | + 'OCA\\TwoFactorBackupCodes\\Event\\CodesGenerated' => __DIR__.'/..'.'/../lib/Event/CodesGenerated.php', |
|
31 | + 'OCA\\TwoFactorBackupCodes\\Listener\\ActivityPublisher' => __DIR__.'/..'.'/../lib/Listener/ActivityPublisher.php', |
|
32 | + 'OCA\\TwoFactorBackupCodes\\Listener\\ClearNotifications' => __DIR__.'/..'.'/../lib/Listener/ClearNotifications.php', |
|
33 | + 'OCA\\TwoFactorBackupCodes\\Listener\\IListener' => __DIR__.'/..'.'/../lib/Listener/IListener.php', |
|
34 | + 'OCA\\TwoFactorBackupCodes\\Listener\\ProviderEnabled' => __DIR__.'/..'.'/../lib/Listener/ProviderEnabled.php', |
|
35 | + 'OCA\\TwoFactorBackupCodes\\Listener\\RegistryUpdater' => __DIR__.'/..'.'/../lib/Listener/RegistryUpdater.php', |
|
36 | + 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607104347' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170607104347.php', |
|
37 | + 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607113030' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170607113030.php', |
|
38 | + 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170919123342' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170919123342.php', |
|
39 | + 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170926101419' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170926101419.php', |
|
40 | + 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20180821043638' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20180821043638.php', |
|
41 | + 'OCA\\TwoFactorBackupCodes\\Notifications\\Notifier' => __DIR__.'/..'.'/../lib/Notifications/Notifier.php', |
|
42 | + 'OCA\\TwoFactorBackupCodes\\Provider\\BackupCodesProvider' => __DIR__.'/..'.'/../lib/Provider/BackupCodesProvider.php', |
|
43 | + 'OCA\\TwoFactorBackupCodes\\Service\\BackupCodeStorage' => __DIR__.'/..'.'/../lib/Service/BackupCodeStorage.php', |
|
44 | + 'OCA\\TwoFactorBackupCodes\\Settings\\Personal' => __DIR__.'/..'.'/../lib/Settings/Personal.php', |
|
45 | 45 | ); |
46 | 46 | |
47 | 47 | public static function getInitializer(ClassLoader $loader) |
48 | 48 | { |
49 | - return \Closure::bind(function () use ($loader) { |
|
49 | + return \Closure::bind(function() use ($loader) { |
|
50 | 50 | $loader->prefixLengthsPsr4 = ComposerStaticInitTwoFactorBackupCodes::$prefixLengthsPsr4; |
51 | 51 | $loader->prefixDirsPsr4 = ComposerStaticInitTwoFactorBackupCodes::$prefixDirsPsr4; |
52 | 52 | $loader->classMap = ComposerStaticInitTwoFactorBackupCodes::$classMap; |