@@ -28,43 +28,43 @@ |
||
28 | 28 | |
29 | 29 | class LazyL10N implements IL10N { |
30 | 30 | |
31 | - /** @var IL10N */ |
|
32 | - private $l; |
|
31 | + /** @var IL10N */ |
|
32 | + private $l; |
|
33 | 33 | |
34 | - /** @var \Closure */ |
|
35 | - private $factory; |
|
34 | + /** @var \Closure */ |
|
35 | + private $factory; |
|
36 | 36 | |
37 | 37 | |
38 | - public function __construct(\Closure $factory) { |
|
39 | - $this->factory = $factory; |
|
40 | - } |
|
38 | + public function __construct(\Closure $factory) { |
|
39 | + $this->factory = $factory; |
|
40 | + } |
|
41 | 41 | |
42 | - private function getL(): IL10N { |
|
43 | - if ($this->l === null) { |
|
44 | - $this->l = ($this->factory)(); |
|
45 | - } |
|
42 | + private function getL(): IL10N { |
|
43 | + if ($this->l === null) { |
|
44 | + $this->l = ($this->factory)(); |
|
45 | + } |
|
46 | 46 | |
47 | - return $this->l; |
|
48 | - } |
|
47 | + return $this->l; |
|
48 | + } |
|
49 | 49 | |
50 | - public function t(string $text, $parameters = []): string { |
|
51 | - return $this->getL()->t($text, $parameters); |
|
52 | - } |
|
50 | + public function t(string $text, $parameters = []): string { |
|
51 | + return $this->getL()->t($text, $parameters); |
|
52 | + } |
|
53 | 53 | |
54 | - public function n(string $text_singular, string $text_plural, int $count, array $parameters = []): string { |
|
55 | - return $this->getL()->n($text_singular, $text_plural, $count, $parameters); |
|
56 | - } |
|
54 | + public function n(string $text_singular, string $text_plural, int $count, array $parameters = []): string { |
|
55 | + return $this->getL()->n($text_singular, $text_plural, $count, $parameters); |
|
56 | + } |
|
57 | 57 | |
58 | - public function l(string $type, $data, array $options = []) { |
|
59 | - return $this->getL()->l($type, $data, $options); |
|
60 | - } |
|
58 | + public function l(string $type, $data, array $options = []) { |
|
59 | + return $this->getL()->l($type, $data, $options); |
|
60 | + } |
|
61 | 61 | |
62 | - public function getLanguageCode(): string { |
|
63 | - return $this->getL()->getLanguageCode(); |
|
64 | - } |
|
62 | + public function getLanguageCode(): string { |
|
63 | + return $this->getL()->getLanguageCode(); |
|
64 | + } |
|
65 | 65 | |
66 | - public function getLocaleCode(): string { |
|
67 | - return $this->getL()->getLocaleCode(); |
|
68 | - } |
|
66 | + public function getLocaleCode(): string { |
|
67 | + return $this->getL()->getLocaleCode(); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |
@@ -30,43 +30,43 @@ |
||
30 | 30 | |
31 | 31 | class RegenerateBirthdayCalendars implements IRepairStep { |
32 | 32 | |
33 | - /** @var IJobList */ |
|
34 | - private $jobList; |
|
33 | + /** @var IJobList */ |
|
34 | + private $jobList; |
|
35 | 35 | |
36 | - /** @var IConfig */ |
|
37 | - private $config; |
|
36 | + /** @var IConfig */ |
|
37 | + private $config; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param IJobList $jobList |
|
41 | - * @param IConfig $config |
|
42 | - */ |
|
43 | - public function __construct(IJobList $jobList, |
|
44 | - IConfig $config) { |
|
45 | - $this->jobList = $jobList; |
|
46 | - $this->config = $config; |
|
47 | - } |
|
39 | + /** |
|
40 | + * @param IJobList $jobList |
|
41 | + * @param IConfig $config |
|
42 | + */ |
|
43 | + public function __construct(IJobList $jobList, |
|
44 | + IConfig $config) { |
|
45 | + $this->jobList = $jobList; |
|
46 | + $this->config = $config; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return 'Regenerating birthday calendars to use new icons and fix old birthday events without year'; |
|
54 | - } |
|
49 | + /** |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return 'Regenerating birthday calendars to use new icons and fix old birthday events without year'; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param IOutput $output |
|
58 | - */ |
|
59 | - public function run(IOutput $output) { |
|
60 | - // only run once |
|
61 | - if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') { |
|
62 | - $output->info('Repair step already executed'); |
|
63 | - return; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @param IOutput $output |
|
58 | + */ |
|
59 | + public function run(IOutput $output) { |
|
60 | + // only run once |
|
61 | + if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') { |
|
62 | + $output->info('Repair step already executed'); |
|
63 | + return; |
|
64 | + } |
|
65 | 65 | |
66 | - $output->info('Adding background jobs to regenerate birthday calendar'); |
|
67 | - $this->jobList->add(RegisterRegenerateBirthdayCalendars::class); |
|
66 | + $output->info('Adding background jobs to regenerate birthday calendar'); |
|
67 | + $this->jobList->add(RegisterRegenerateBirthdayCalendars::class); |
|
68 | 68 | |
69 | - // if all were done, no need to redo the repair during next upgrade |
|
70 | - $this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes'); |
|
71 | - } |
|
69 | + // if all were done, no need to redo the repair during next upgrade |
|
70 | + $this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes'); |
|
71 | + } |
|
72 | 72 | } |
@@ -26,88 +26,88 @@ |
||
26 | 26 | use OCP\IUser; |
27 | 27 | |
28 | 28 | class Version implements IVersion { |
29 | - /** @var int */ |
|
30 | - private $timestamp; |
|
31 | - |
|
32 | - /** @var int|string */ |
|
33 | - private $revisionId; |
|
34 | - |
|
35 | - /** @var string */ |
|
36 | - private $name; |
|
37 | - |
|
38 | - /** @var int */ |
|
39 | - private $size; |
|
40 | - |
|
41 | - /** @var string */ |
|
42 | - private $mimetype; |
|
43 | - |
|
44 | - /** @var string */ |
|
45 | - private $path; |
|
46 | - |
|
47 | - /** @var FileInfo */ |
|
48 | - private $sourceFileInfo; |
|
49 | - |
|
50 | - /** @var IVersionBackend */ |
|
51 | - private $backend; |
|
52 | - |
|
53 | - /** @var IUser */ |
|
54 | - private $user; |
|
55 | - |
|
56 | - public function __construct( |
|
57 | - int $timestamp, |
|
58 | - $revisionId, |
|
59 | - string $name, |
|
60 | - int $size, |
|
61 | - string $mimetype, |
|
62 | - string $path, |
|
63 | - FileInfo $sourceFileInfo, |
|
64 | - IVersionBackend $backend, |
|
65 | - IUser $user |
|
66 | - ) { |
|
67 | - $this->timestamp = $timestamp; |
|
68 | - $this->revisionId = $revisionId; |
|
69 | - $this->name = $name; |
|
70 | - $this->size = $size; |
|
71 | - $this->mimetype = $mimetype; |
|
72 | - $this->path = $path; |
|
73 | - $this->sourceFileInfo = $sourceFileInfo; |
|
74 | - $this->backend = $backend; |
|
75 | - $this->user = $user; |
|
76 | - } |
|
77 | - |
|
78 | - public function getBackend(): IVersionBackend { |
|
79 | - return $this->backend; |
|
80 | - } |
|
81 | - |
|
82 | - public function getSourceFile(): FileInfo { |
|
83 | - return $this->sourceFileInfo; |
|
84 | - } |
|
85 | - |
|
86 | - public function getRevisionId() { |
|
87 | - return $this->revisionId; |
|
88 | - } |
|
89 | - |
|
90 | - public function getTimestamp(): int { |
|
91 | - return $this->timestamp; |
|
92 | - } |
|
93 | - |
|
94 | - public function getSize(): int { |
|
95 | - return $this->size; |
|
96 | - } |
|
97 | - |
|
98 | - public function getSourceFileName(): string { |
|
99 | - return $this->name; |
|
100 | - } |
|
101 | - |
|
102 | - public function getMimeType(): string { |
|
103 | - return $this->mimetype; |
|
104 | - } |
|
105 | - |
|
106 | - public function getVersionPath(): string { |
|
107 | - return $this->path; |
|
108 | - } |
|
109 | - |
|
110 | - public function getUser(): IUser { |
|
111 | - return $this->user; |
|
112 | - } |
|
29 | + /** @var int */ |
|
30 | + private $timestamp; |
|
31 | + |
|
32 | + /** @var int|string */ |
|
33 | + private $revisionId; |
|
34 | + |
|
35 | + /** @var string */ |
|
36 | + private $name; |
|
37 | + |
|
38 | + /** @var int */ |
|
39 | + private $size; |
|
40 | + |
|
41 | + /** @var string */ |
|
42 | + private $mimetype; |
|
43 | + |
|
44 | + /** @var string */ |
|
45 | + private $path; |
|
46 | + |
|
47 | + /** @var FileInfo */ |
|
48 | + private $sourceFileInfo; |
|
49 | + |
|
50 | + /** @var IVersionBackend */ |
|
51 | + private $backend; |
|
52 | + |
|
53 | + /** @var IUser */ |
|
54 | + private $user; |
|
55 | + |
|
56 | + public function __construct( |
|
57 | + int $timestamp, |
|
58 | + $revisionId, |
|
59 | + string $name, |
|
60 | + int $size, |
|
61 | + string $mimetype, |
|
62 | + string $path, |
|
63 | + FileInfo $sourceFileInfo, |
|
64 | + IVersionBackend $backend, |
|
65 | + IUser $user |
|
66 | + ) { |
|
67 | + $this->timestamp = $timestamp; |
|
68 | + $this->revisionId = $revisionId; |
|
69 | + $this->name = $name; |
|
70 | + $this->size = $size; |
|
71 | + $this->mimetype = $mimetype; |
|
72 | + $this->path = $path; |
|
73 | + $this->sourceFileInfo = $sourceFileInfo; |
|
74 | + $this->backend = $backend; |
|
75 | + $this->user = $user; |
|
76 | + } |
|
77 | + |
|
78 | + public function getBackend(): IVersionBackend { |
|
79 | + return $this->backend; |
|
80 | + } |
|
81 | + |
|
82 | + public function getSourceFile(): FileInfo { |
|
83 | + return $this->sourceFileInfo; |
|
84 | + } |
|
85 | + |
|
86 | + public function getRevisionId() { |
|
87 | + return $this->revisionId; |
|
88 | + } |
|
89 | + |
|
90 | + public function getTimestamp(): int { |
|
91 | + return $this->timestamp; |
|
92 | + } |
|
93 | + |
|
94 | + public function getSize(): int { |
|
95 | + return $this->size; |
|
96 | + } |
|
97 | + |
|
98 | + public function getSourceFileName(): string { |
|
99 | + return $this->name; |
|
100 | + } |
|
101 | + |
|
102 | + public function getMimeType(): string { |
|
103 | + return $this->mimetype; |
|
104 | + } |
|
105 | + |
|
106 | + public function getVersionPath(): string { |
|
107 | + return $this->path; |
|
108 | + } |
|
109 | + |
|
110 | + public function getUser(): IUser { |
|
111 | + return $this->user; |
|
112 | + } |
|
113 | 113 | } |
@@ -29,71 +29,71 @@ |
||
29 | 29 | * @since 15.0.0 |
30 | 30 | */ |
31 | 31 | interface IVersion { |
32 | - /** |
|
33 | - * @return IVersionBackend |
|
34 | - * @since 15.0.0 |
|
35 | - */ |
|
36 | - public function getBackend(): IVersionBackend; |
|
32 | + /** |
|
33 | + * @return IVersionBackend |
|
34 | + * @since 15.0.0 |
|
35 | + */ |
|
36 | + public function getBackend(): IVersionBackend; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Get the file info of the source file |
|
40 | - * |
|
41 | - * @return FileInfo |
|
42 | - * @since 15.0.0 |
|
43 | - */ |
|
44 | - public function getSourceFile(): FileInfo; |
|
38 | + /** |
|
39 | + * Get the file info of the source file |
|
40 | + * |
|
41 | + * @return FileInfo |
|
42 | + * @since 15.0.0 |
|
43 | + */ |
|
44 | + public function getSourceFile(): FileInfo; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get the id of the revision for the file |
|
48 | - * |
|
49 | - * @return int|string |
|
50 | - * @since 15.0.0 |
|
51 | - */ |
|
52 | - public function getRevisionId(); |
|
46 | + /** |
|
47 | + * Get the id of the revision for the file |
|
48 | + * |
|
49 | + * @return int|string |
|
50 | + * @since 15.0.0 |
|
51 | + */ |
|
52 | + public function getRevisionId(); |
|
53 | 53 | |
54 | - /** |
|
55 | - * Get the timestamp this version was created |
|
56 | - * |
|
57 | - * @return int |
|
58 | - * @since 15.0.0 |
|
59 | - */ |
|
60 | - public function getTimestamp(): int; |
|
54 | + /** |
|
55 | + * Get the timestamp this version was created |
|
56 | + * |
|
57 | + * @return int |
|
58 | + * @since 15.0.0 |
|
59 | + */ |
|
60 | + public function getTimestamp(): int; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Get the size of this version |
|
64 | - * |
|
65 | - * @return int |
|
66 | - * @since 15.0.0 |
|
67 | - */ |
|
68 | - public function getSize(): int; |
|
62 | + /** |
|
63 | + * Get the size of this version |
|
64 | + * |
|
65 | + * @return int |
|
66 | + * @since 15.0.0 |
|
67 | + */ |
|
68 | + public function getSize(): int; |
|
69 | 69 | |
70 | - /** |
|
71 | - * Get the name of the source file at the time of making this version |
|
72 | - * |
|
73 | - * @return string |
|
74 | - * @since 15.0.0 |
|
75 | - */ |
|
76 | - public function getSourceFileName(): string; |
|
70 | + /** |
|
71 | + * Get the name of the source file at the time of making this version |
|
72 | + * |
|
73 | + * @return string |
|
74 | + * @since 15.0.0 |
|
75 | + */ |
|
76 | + public function getSourceFileName(): string; |
|
77 | 77 | |
78 | - /** |
|
79 | - * Get the mimetype of this version |
|
80 | - * |
|
81 | - * @return string |
|
82 | - * @since 15.0.0 |
|
83 | - */ |
|
84 | - public function getMimeType(): string; |
|
78 | + /** |
|
79 | + * Get the mimetype of this version |
|
80 | + * |
|
81 | + * @return string |
|
82 | + * @since 15.0.0 |
|
83 | + */ |
|
84 | + public function getMimeType(): string; |
|
85 | 85 | |
86 | - /** |
|
87 | - * Get the path of this version |
|
88 | - * |
|
89 | - * @return string |
|
90 | - * @since 15.0.0 |
|
91 | - */ |
|
92 | - public function getVersionPath(): string; |
|
86 | + /** |
|
87 | + * Get the path of this version |
|
88 | + * |
|
89 | + * @return string |
|
90 | + * @since 15.0.0 |
|
91 | + */ |
|
92 | + public function getVersionPath(): string; |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return IUser |
|
96 | - * @since 15.0.0 |
|
97 | - */ |
|
98 | - public function getUser(): IUser; |
|
94 | + /** |
|
95 | + * @return IUser |
|
96 | + * @since 15.0.0 |
|
97 | + */ |
|
98 | + public function getUser(): IUser; |
|
99 | 99 | } |
@@ -26,68 +26,68 @@ |
||
26 | 26 | |
27 | 27 | interface ILDAPUserPlugin { |
28 | 28 | |
29 | - /** |
|
30 | - * Check if plugin implements actions |
|
31 | - * @return int |
|
32 | - * |
|
33 | - * Returns the supported actions as int to be |
|
34 | - * compared with OC_USER_BACKEND_CREATE_USER etc. |
|
35 | - */ |
|
36 | - public function respondToActions(); |
|
29 | + /** |
|
30 | + * Check if plugin implements actions |
|
31 | + * @return int |
|
32 | + * |
|
33 | + * Returns the supported actions as int to be |
|
34 | + * compared with OC_USER_BACKEND_CREATE_USER etc. |
|
35 | + */ |
|
36 | + public function respondToActions(); |
|
37 | 37 | |
38 | - /** |
|
39 | - * Create a new user in LDAP Backend |
|
40 | - * |
|
41 | - * @param string $uid The UID of the user to create |
|
42 | - * @param string $password The password of the new user |
|
43 | - * @return bool|string |
|
44 | - */ |
|
45 | - public function createUser($uid, $password); |
|
38 | + /** |
|
39 | + * Create a new user in LDAP Backend |
|
40 | + * |
|
41 | + * @param string $uid The UID of the user to create |
|
42 | + * @param string $password The password of the new user |
|
43 | + * @return bool|string |
|
44 | + */ |
|
45 | + public function createUser($uid, $password); |
|
46 | 46 | |
47 | - /** |
|
48 | - * Set password |
|
49 | - * |
|
50 | - * @param string $uid The username |
|
51 | - * @param string $password The new password |
|
52 | - * @return bool |
|
53 | - * |
|
54 | - * Change the password of a user |
|
55 | - */ |
|
56 | - public function setPassword($uid, $password); |
|
47 | + /** |
|
48 | + * Set password |
|
49 | + * |
|
50 | + * @param string $uid The username |
|
51 | + * @param string $password The new password |
|
52 | + * @return bool |
|
53 | + * |
|
54 | + * Change the password of a user |
|
55 | + */ |
|
56 | + public function setPassword($uid, $password); |
|
57 | 57 | |
58 | - /** |
|
59 | - * get the user's home directory |
|
60 | - * @param string $uid the username |
|
61 | - * @return boolean |
|
62 | - */ |
|
63 | - public function getHome($uid); |
|
58 | + /** |
|
59 | + * get the user's home directory |
|
60 | + * @param string $uid the username |
|
61 | + * @return boolean |
|
62 | + */ |
|
63 | + public function getHome($uid); |
|
64 | 64 | |
65 | - /** |
|
66 | - * get display name of the user |
|
67 | - * @param string $uid user ID of the user |
|
68 | - * @return string display name |
|
69 | - */ |
|
70 | - public function getDisplayName($uid); |
|
65 | + /** |
|
66 | + * get display name of the user |
|
67 | + * @param string $uid user ID of the user |
|
68 | + * @return string display name |
|
69 | + */ |
|
70 | + public function getDisplayName($uid); |
|
71 | 71 | |
72 | - /** |
|
73 | - * set display name of the user |
|
74 | - * @param string $uid user ID of the user |
|
75 | - * @param string $displayName new user's display name |
|
76 | - * @return string display name |
|
77 | - */ |
|
78 | - public function setDisplayName($uid, $displayName); |
|
72 | + /** |
|
73 | + * set display name of the user |
|
74 | + * @param string $uid user ID of the user |
|
75 | + * @param string $displayName new user's display name |
|
76 | + * @return string display name |
|
77 | + */ |
|
78 | + public function setDisplayName($uid, $displayName); |
|
79 | 79 | |
80 | - /** |
|
81 | - * checks whether the user is allowed to change his avatar in Nextcloud |
|
82 | - * @param string $uid the Nextcloud user name |
|
83 | - * @return boolean either the user can or cannot |
|
84 | - */ |
|
85 | - public function canChangeAvatar($uid); |
|
80 | + /** |
|
81 | + * checks whether the user is allowed to change his avatar in Nextcloud |
|
82 | + * @param string $uid the Nextcloud user name |
|
83 | + * @return boolean either the user can or cannot |
|
84 | + */ |
|
85 | + public function canChangeAvatar($uid); |
|
86 | 86 | |
87 | - /** |
|
88 | - * Count the number of users |
|
89 | - * @return int|bool |
|
90 | - */ |
|
91 | - public function countUsers(); |
|
87 | + /** |
|
88 | + * Count the number of users |
|
89 | + * @return int|bool |
|
90 | + */ |
|
91 | + public function countUsers(); |
|
92 | 92 | |
93 | 93 | } |
@@ -35,33 +35,33 @@ |
||
35 | 35 | |
36 | 36 | class ProviderDisabled implements IEventListener { |
37 | 37 | |
38 | - /** @var IRegistry */ |
|
39 | - private $registry; |
|
38 | + /** @var IRegistry */ |
|
39 | + private $registry; |
|
40 | 40 | |
41 | - /** @var IJobList */ |
|
42 | - private $jobList; |
|
41 | + /** @var IJobList */ |
|
42 | + private $jobList; |
|
43 | 43 | |
44 | - public function __construct(IRegistry $registry, |
|
45 | - IJobList $jobList) { |
|
46 | - $this->registry = $registry; |
|
47 | - $this->jobList = $jobList; |
|
48 | - } |
|
44 | + public function __construct(IRegistry $registry, |
|
45 | + IJobList $jobList) { |
|
46 | + $this->registry = $registry; |
|
47 | + $this->jobList = $jobList; |
|
48 | + } |
|
49 | 49 | |
50 | - public function handle(Event $event): void { |
|
51 | - if (!($event instanceof RegistryEvent)) { |
|
52 | - return; |
|
53 | - } |
|
50 | + public function handle(Event $event): void { |
|
51 | + if (!($event instanceof RegistryEvent)) { |
|
52 | + return; |
|
53 | + } |
|
54 | 54 | |
55 | - $providers = $this->registry->getProviderStates($event->getUser()); |
|
55 | + $providers = $this->registry->getProviderStates($event->getUser()); |
|
56 | 56 | |
57 | - // Loop over all providers. If all are disabled we remove the job |
|
58 | - $state = array_reduce($providers, function (bool $carry, bool $enabled) { |
|
59 | - return $carry || $enabled; |
|
60 | - }, false); |
|
57 | + // Loop over all providers. If all are disabled we remove the job |
|
58 | + $state = array_reduce($providers, function (bool $carry, bool $enabled) { |
|
59 | + return $carry || $enabled; |
|
60 | + }, false); |
|
61 | 61 | |
62 | - if ($state === false) { |
|
63 | - $this->jobList->remove(RememberBackupCodesJob::class, ['uid' => $event->getUser()->getUID()]); |
|
64 | - } |
|
65 | - } |
|
62 | + if ($state === false) { |
|
63 | + $this->jobList->remove(RememberBackupCodesJob::class, ['uid' => $event->getUser()->getUID()]); |
|
64 | + } |
|
65 | + } |
|
66 | 66 | |
67 | 67 | } |
@@ -33,30 +33,30 @@ |
||
33 | 33 | |
34 | 34 | class ProviderEnabled implements IEventListener { |
35 | 35 | |
36 | - /** @var IRegistry */ |
|
37 | - private $registry; |
|
38 | - |
|
39 | - /** @var IJobList */ |
|
40 | - private $jobList; |
|
41 | - |
|
42 | - public function __construct(IRegistry $registry, |
|
43 | - IJobList $jobList) { |
|
44 | - $this->registry = $registry; |
|
45 | - $this->jobList = $jobList; |
|
46 | - } |
|
47 | - |
|
48 | - public function handle(Event $event): void { |
|
49 | - if (!($event instanceof RegistryEvent)) { |
|
50 | - return; |
|
51 | - } |
|
52 | - |
|
53 | - $providers = $this->registry->getProviderStates($event->getUser()); |
|
54 | - if (isset($providers['backup_codes']) && $providers['backup_codes'] === true) { |
|
55 | - // Backup codes already generated nothing to do here |
|
56 | - return; |
|
57 | - } |
|
58 | - |
|
59 | - $this->jobList->add(RememberBackupCodesJob::class, ['uid' => $event->getUser()->getUID()]); |
|
60 | - } |
|
36 | + /** @var IRegistry */ |
|
37 | + private $registry; |
|
38 | + |
|
39 | + /** @var IJobList */ |
|
40 | + private $jobList; |
|
41 | + |
|
42 | + public function __construct(IRegistry $registry, |
|
43 | + IJobList $jobList) { |
|
44 | + $this->registry = $registry; |
|
45 | + $this->jobList = $jobList; |
|
46 | + } |
|
47 | + |
|
48 | + public function handle(Event $event): void { |
|
49 | + if (!($event instanceof RegistryEvent)) { |
|
50 | + return; |
|
51 | + } |
|
52 | + |
|
53 | + $providers = $this->registry->getProviderStates($event->getUser()); |
|
54 | + if (isset($providers['backup_codes']) && $providers['backup_codes'] === true) { |
|
55 | + // Backup codes already generated nothing to do here |
|
56 | + return; |
|
57 | + } |
|
58 | + |
|
59 | + $this->jobList->add(RememberBackupCodesJob::class, ['uid' => $event->getUser()->getUID()]); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | } |
@@ -33,22 +33,22 @@ |
||
33 | 33 | |
34 | 34 | class ClearNotifications implements IEventListener { |
35 | 35 | |
36 | - /** @var IManager */ |
|
37 | - private $manager; |
|
38 | - |
|
39 | - public function __construct(IManager $manager) { |
|
40 | - $this->manager = $manager; |
|
41 | - } |
|
42 | - |
|
43 | - public function handle(Event $event): void { |
|
44 | - if (!($event instanceof CodesGenerated)) { |
|
45 | - return; |
|
46 | - } |
|
47 | - |
|
48 | - $notification = $this->manager->createNotification(); |
|
49 | - $notification->setApp('twofactor_backupcodes') |
|
50 | - ->setUser($event->getUser()->getUID()) |
|
51 | - ->setObject('create', 'codes'); |
|
52 | - $this->manager->markProcessed($notification); |
|
53 | - } |
|
36 | + /** @var IManager */ |
|
37 | + private $manager; |
|
38 | + |
|
39 | + public function __construct(IManager $manager) { |
|
40 | + $this->manager = $manager; |
|
41 | + } |
|
42 | + |
|
43 | + public function handle(Event $event): void { |
|
44 | + if (!($event instanceof CodesGenerated)) { |
|
45 | + return; |
|
46 | + } |
|
47 | + |
|
48 | + $notification = $this->manager->createNotification(); |
|
49 | + $notification->setApp('twofactor_backupcodes') |
|
50 | + ->setUser($event->getUser()->getUID()) |
|
51 | + ->setObject('create', 'codes'); |
|
52 | + $this->manager->markProcessed($notification); |
|
53 | + } |
|
54 | 54 | } |
@@ -33,36 +33,36 @@ |
||
33 | 33 | |
34 | 34 | class ActivityPublisher implements IEventListener { |
35 | 35 | |
36 | - /** @var IManager */ |
|
37 | - private $activityManager; |
|
36 | + /** @var IManager */ |
|
37 | + private $activityManager; |
|
38 | 38 | |
39 | - /** @var ILogger */ |
|
40 | - private $logger; |
|
39 | + /** @var ILogger */ |
|
40 | + private $logger; |
|
41 | 41 | |
42 | - public function __construct(IManager $activityManager, |
|
43 | - ILogger $logger) { |
|
44 | - $this->activityManager = $activityManager; |
|
45 | - $this->logger = $logger; |
|
46 | - } |
|
42 | + public function __construct(IManager $activityManager, |
|
43 | + ILogger $logger) { |
|
44 | + $this->activityManager = $activityManager; |
|
45 | + $this->logger = $logger; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Push an event to the user's activity stream |
|
50 | - */ |
|
51 | - public function handle(Event $event): void { |
|
52 | - if ($event instanceof CodesGenerated) { |
|
53 | - $activity = $this->activityManager->generateEvent(); |
|
54 | - $activity->setApp('twofactor_backupcodes') |
|
55 | - ->setType('security') |
|
56 | - ->setAuthor($event->getUser()->getUID()) |
|
57 | - ->setAffectedUser($event->getUser()->getUID()) |
|
58 | - ->setSubject('codes_generated'); |
|
59 | - try { |
|
60 | - $this->activityManager->publish($activity); |
|
61 | - } catch (BadMethodCallException $e) { |
|
62 | - $this->logger->warning('could not publish backup code creation activity', ['app' => 'twofactor_backupcodes']); |
|
63 | - $this->logger->logException($e, ['app' => 'twofactor_backupcodes']); |
|
64 | - } |
|
65 | - } |
|
66 | - } |
|
48 | + /** |
|
49 | + * Push an event to the user's activity stream |
|
50 | + */ |
|
51 | + public function handle(Event $event): void { |
|
52 | + if ($event instanceof CodesGenerated) { |
|
53 | + $activity = $this->activityManager->generateEvent(); |
|
54 | + $activity->setApp('twofactor_backupcodes') |
|
55 | + ->setType('security') |
|
56 | + ->setAuthor($event->getUser()->getUID()) |
|
57 | + ->setAffectedUser($event->getUser()->getUID()) |
|
58 | + ->setSubject('codes_generated'); |
|
59 | + try { |
|
60 | + $this->activityManager->publish($activity); |
|
61 | + } catch (BadMethodCallException $e) { |
|
62 | + $this->logger->warning('could not publish backup code creation activity', ['app' => 'twofactor_backupcodes']); |
|
63 | + $this->logger->logException($e, ['app' => 'twofactor_backupcodes']); |
|
64 | + } |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | } |