@@ -106,12 +106,12 @@ |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | return [ |
109 | - 'providers' => array_map(function (IProvidesPersonalSettings $provider) use ($user) { |
|
109 | + 'providers' => array_map(function(IProvidesPersonalSettings $provider) use ($user) { |
|
110 | 110 | return [ |
111 | 111 | 'provider' => $provider, |
112 | 112 | 'settings' => $provider->getPersonalSettings($user) |
113 | 113 | ]; |
114 | - }, array_filter($this->providerLoader->getProviders($user), function (IProvider $provider) { |
|
114 | + }, array_filter($this->providerLoader->getProviders($user), function(IProvider $provider) { |
|
115 | 115 | return $provider instanceof IProvidesPersonalSettings; |
116 | 116 | })) |
117 | 117 | ]; |
@@ -24,85 +24,85 @@ |
||
24 | 24 | |
25 | 25 | class TwoFactor implements ISettings { |
26 | 26 | |
27 | - /** @var ProviderLoader */ |
|
28 | - private $providerLoader; |
|
27 | + /** @var ProviderLoader */ |
|
28 | + private $providerLoader; |
|
29 | 29 | |
30 | - /** @var MandatoryTwoFactor */ |
|
31 | - private $mandatoryTwoFactor; |
|
30 | + /** @var MandatoryTwoFactor */ |
|
31 | + private $mandatoryTwoFactor; |
|
32 | 32 | |
33 | - public function __construct( |
|
34 | - ProviderLoader $providerLoader, |
|
35 | - MandatoryTwoFactor $mandatoryTwoFactor, |
|
36 | - private IUserSession $userSession, |
|
37 | - private IConfig $config, |
|
38 | - private ?string $userId, |
|
39 | - ) { |
|
40 | - $this->providerLoader = $providerLoader; |
|
41 | - $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
42 | - } |
|
33 | + public function __construct( |
|
34 | + ProviderLoader $providerLoader, |
|
35 | + MandatoryTwoFactor $mandatoryTwoFactor, |
|
36 | + private IUserSession $userSession, |
|
37 | + private IConfig $config, |
|
38 | + private ?string $userId, |
|
39 | + ) { |
|
40 | + $this->providerLoader = $providerLoader; |
|
41 | + $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getForm(): TemplateResponse { |
|
45 | - return new TemplateResponse('settings', 'settings/personal/security/twofactor', [ |
|
46 | - 'twoFactorProviderData' => $this->getTwoFactorProviderData(), |
|
47 | - ]); |
|
48 | - } |
|
44 | + public function getForm(): TemplateResponse { |
|
45 | + return new TemplateResponse('settings', 'settings/personal/security/twofactor', [ |
|
46 | + 'twoFactorProviderData' => $this->getTwoFactorProviderData(), |
|
47 | + ]); |
|
48 | + } |
|
49 | 49 | |
50 | - public function getSection(): ?string { |
|
51 | - if (!$this->shouldShow()) { |
|
52 | - return null; |
|
53 | - } |
|
54 | - return 'security'; |
|
55 | - } |
|
50 | + public function getSection(): ?string { |
|
51 | + if (!$this->shouldShow()) { |
|
52 | + return null; |
|
53 | + } |
|
54 | + return 'security'; |
|
55 | + } |
|
56 | 56 | |
57 | - public function getPriority(): int { |
|
58 | - return 15; |
|
59 | - } |
|
57 | + public function getPriority(): int { |
|
58 | + return 15; |
|
59 | + } |
|
60 | 60 | |
61 | - private function shouldShow(): bool { |
|
62 | - $user = $this->userSession->getUser(); |
|
63 | - if (is_null($user)) { |
|
64 | - // Actually impossible, but still … |
|
65 | - return false; |
|
66 | - } |
|
61 | + private function shouldShow(): bool { |
|
62 | + $user = $this->userSession->getUser(); |
|
63 | + if (is_null($user)) { |
|
64 | + // Actually impossible, but still … |
|
65 | + return false; |
|
66 | + } |
|
67 | 67 | |
68 | - // Anyone who's supposed to use 2FA should see 2FA settings |
|
69 | - if ($this->mandatoryTwoFactor->isEnforcedFor($user)) { |
|
70 | - return true; |
|
71 | - } |
|
68 | + // Anyone who's supposed to use 2FA should see 2FA settings |
|
69 | + if ($this->mandatoryTwoFactor->isEnforcedFor($user)) { |
|
70 | + return true; |
|
71 | + } |
|
72 | 72 | |
73 | - // If there is at least one provider with personal settings but it's not |
|
74 | - // the backup codes provider, then these settings should show. |
|
75 | - try { |
|
76 | - $providers = $this->providerLoader->getProviders($user); |
|
77 | - } catch (Exception $e) { |
|
78 | - // Let's hope for the best |
|
79 | - return true; |
|
80 | - } |
|
81 | - foreach ($providers as $provider) { |
|
82 | - if ($provider instanceof IProvidesPersonalSettings |
|
83 | - && !($provider instanceof BackupCodesProvider)) { |
|
84 | - return true; |
|
85 | - } |
|
86 | - } |
|
87 | - return false; |
|
88 | - } |
|
73 | + // If there is at least one provider with personal settings but it's not |
|
74 | + // the backup codes provider, then these settings should show. |
|
75 | + try { |
|
76 | + $providers = $this->providerLoader->getProviders($user); |
|
77 | + } catch (Exception $e) { |
|
78 | + // Let's hope for the best |
|
79 | + return true; |
|
80 | + } |
|
81 | + foreach ($providers as $provider) { |
|
82 | + if ($provider instanceof IProvidesPersonalSettings |
|
83 | + && !($provider instanceof BackupCodesProvider)) { |
|
84 | + return true; |
|
85 | + } |
|
86 | + } |
|
87 | + return false; |
|
88 | + } |
|
89 | 89 | |
90 | - private function getTwoFactorProviderData(): array { |
|
91 | - $user = $this->userSession->getUser(); |
|
92 | - if (is_null($user)) { |
|
93 | - // Actually impossible, but still … |
|
94 | - return []; |
|
95 | - } |
|
90 | + private function getTwoFactorProviderData(): array { |
|
91 | + $user = $this->userSession->getUser(); |
|
92 | + if (is_null($user)) { |
|
93 | + // Actually impossible, but still … |
|
94 | + return []; |
|
95 | + } |
|
96 | 96 | |
97 | - return [ |
|
98 | - 'providers' => array_map(function (IProvidesPersonalSettings $provider) use ($user) { |
|
99 | - return [ |
|
100 | - 'provider' => $provider, |
|
101 | - 'settings' => $provider->getPersonalSettings($user) |
|
102 | - ]; |
|
103 | - }, array_filter($this->providerLoader->getProviders($user), function (IProvider $provider) { |
|
104 | - return $provider instanceof IProvidesPersonalSettings; |
|
105 | - })) |
|
106 | - ]; |
|
107 | - } |
|
97 | + return [ |
|
98 | + 'providers' => array_map(function (IProvidesPersonalSettings $provider) use ($user) { |
|
99 | + return [ |
|
100 | + 'provider' => $provider, |
|
101 | + 'settings' => $provider->getPersonalSettings($user) |
|
102 | + ]; |
|
103 | + }, array_filter($this->providerLoader->getProviders($user), function (IProvider $provider) { |
|
104 | + return $provider instanceof IProvidesPersonalSettings; |
|
105 | + })) |
|
106 | + ]; |
|
107 | + } |
|
108 | 108 | } |
@@ -32,42 +32,42 @@ |
||
32 | 32 | */ |
33 | 33 | interface ICalendarProvider { |
34 | 34 | |
35 | - /** |
|
36 | - * Provides the appId of the plugin |
|
37 | - * |
|
38 | - * @since 19.0.0 |
|
39 | - * @return string AppId |
|
40 | - */ |
|
41 | - public function getAppId(): string; |
|
35 | + /** |
|
36 | + * Provides the appId of the plugin |
|
37 | + * |
|
38 | + * @since 19.0.0 |
|
39 | + * @return string AppId |
|
40 | + */ |
|
41 | + public function getAppId(): string; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Fetches all calendars for a given principal uri |
|
45 | - * |
|
46 | - * @since 19.0.0 |
|
47 | - * @param string $principalUri E.g. principals/users/user1 |
|
48 | - * @return ExternalCalendar[] Array of all calendars |
|
49 | - */ |
|
50 | - public function fetchAllForCalendarHome(string $principalUri): array; |
|
43 | + /** |
|
44 | + * Fetches all calendars for a given principal uri |
|
45 | + * |
|
46 | + * @since 19.0.0 |
|
47 | + * @param string $principalUri E.g. principals/users/user1 |
|
48 | + * @return ExternalCalendar[] Array of all calendars |
|
49 | + */ |
|
50 | + public function fetchAllForCalendarHome(string $principalUri): array; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Checks whether plugin has a calendar for a given principalUri and calendarUri |
|
54 | - * |
|
55 | - * @since 19.0.0 |
|
56 | - * @param string $principalUri E.g. principals/users/user1 |
|
57 | - * @param string $calendarUri E.g. personal |
|
58 | - * @return bool True if calendar for principalUri and calendarUri exists, false otherwise |
|
59 | - */ |
|
60 | - public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool; |
|
52 | + /** |
|
53 | + * Checks whether plugin has a calendar for a given principalUri and calendarUri |
|
54 | + * |
|
55 | + * @since 19.0.0 |
|
56 | + * @param string $principalUri E.g. principals/users/user1 |
|
57 | + * @param string $calendarUri E.g. personal |
|
58 | + * @return bool True if calendar for principalUri and calendarUri exists, false otherwise |
|
59 | + */ |
|
60 | + public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Fetches a calendar for a given principalUri and calendarUri |
|
64 | - * Returns null if calendar does not exist |
|
65 | - * |
|
66 | - * @since 19.0.0 |
|
67 | - * @param string $principalUri E.g. principals/users/user1 |
|
68 | - * @param string $calendarUri E.g. personal |
|
69 | - * @return ExternalCalendar|null Calendar if it exists, null otherwise |
|
70 | - */ |
|
71 | - public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar; |
|
62 | + /** |
|
63 | + * Fetches a calendar for a given principalUri and calendarUri |
|
64 | + * Returns null if calendar does not exist |
|
65 | + * |
|
66 | + * @since 19.0.0 |
|
67 | + * @param string $principalUri E.g. principals/users/user1 |
|
68 | + * @param string $calendarUri E.g. personal |
|
69 | + * @return ExternalCalendar|null Calendar if it exists, null otherwise |
|
70 | + */ |
|
71 | + public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar; |
|
72 | 72 | |
73 | 73 | } |
@@ -33,61 +33,61 @@ |
||
33 | 33 | |
34 | 34 | class Version010000Date20200304152605 extends SimpleMigrationStep { |
35 | 35 | |
36 | - /** |
|
37 | - * @param IOutput $output |
|
38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | - * @param array $options |
|
40 | - * |
|
41 | - * @return ISchemaWrapper |
|
42 | - */ |
|
43 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
44 | - /** @var ISchemaWrapper $schema */ |
|
45 | - $schema = $schemaClosure(); |
|
36 | + /** |
|
37 | + * @param IOutput $output |
|
38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | + * @param array $options |
|
40 | + * |
|
41 | + * @return ISchemaWrapper |
|
42 | + */ |
|
43 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
44 | + /** @var ISchemaWrapper $schema */ |
|
45 | + $schema = $schemaClosure(); |
|
46 | 46 | |
47 | - $table = $schema->createTable(RecentContactMapper::TABLE_NAME); |
|
48 | - $table->addColumn('id', 'integer', [ |
|
49 | - 'autoincrement' => true, |
|
50 | - 'notnull' => true, |
|
51 | - 'length' => 4, |
|
52 | - ]); |
|
53 | - $table->addColumn('actor_uid', 'string', [ |
|
54 | - 'notnull' => true, |
|
55 | - 'length' => 64, |
|
56 | - ]); |
|
57 | - $table->addColumn('uid', 'string', [ |
|
58 | - 'notnull' => false, |
|
59 | - 'length' => 64, |
|
60 | - ]); |
|
61 | - $table->addColumn('email', 'string', [ |
|
62 | - 'notnull' => false, |
|
63 | - 'length' => 255, |
|
64 | - ]); |
|
65 | - $table->addColumn('federated_cloud_id', 'string', [ |
|
66 | - 'notnull' => false, |
|
67 | - 'length' => 255, |
|
68 | - ]); |
|
69 | - $table->addColumn('card', 'blob', [ |
|
70 | - 'notnull' => true, |
|
71 | - ]); |
|
72 | - $table->addColumn('last_contact', 'integer', [ |
|
73 | - 'notnull' => true, |
|
74 | - 'length' => 4, |
|
75 | - ]); |
|
76 | - $table->setPrimaryKey(['id']); |
|
77 | - // To find all recent entries |
|
78 | - $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
79 | - // To find a specific entry |
|
80 | - $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
81 | - // To find all recent entries with a given UID |
|
82 | - $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
83 | - // To find all recent entries with a given email address |
|
84 | - $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
85 | - // To find all recent entries with a give federated cloud id |
|
86 | - $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
87 | - // For the cleanup |
|
88 | - $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
47 | + $table = $schema->createTable(RecentContactMapper::TABLE_NAME); |
|
48 | + $table->addColumn('id', 'integer', [ |
|
49 | + 'autoincrement' => true, |
|
50 | + 'notnull' => true, |
|
51 | + 'length' => 4, |
|
52 | + ]); |
|
53 | + $table->addColumn('actor_uid', 'string', [ |
|
54 | + 'notnull' => true, |
|
55 | + 'length' => 64, |
|
56 | + ]); |
|
57 | + $table->addColumn('uid', 'string', [ |
|
58 | + 'notnull' => false, |
|
59 | + 'length' => 64, |
|
60 | + ]); |
|
61 | + $table->addColumn('email', 'string', [ |
|
62 | + 'notnull' => false, |
|
63 | + 'length' => 255, |
|
64 | + ]); |
|
65 | + $table->addColumn('federated_cloud_id', 'string', [ |
|
66 | + 'notnull' => false, |
|
67 | + 'length' => 255, |
|
68 | + ]); |
|
69 | + $table->addColumn('card', 'blob', [ |
|
70 | + 'notnull' => true, |
|
71 | + ]); |
|
72 | + $table->addColumn('last_contact', 'integer', [ |
|
73 | + 'notnull' => true, |
|
74 | + 'length' => 4, |
|
75 | + ]); |
|
76 | + $table->setPrimaryKey(['id']); |
|
77 | + // To find all recent entries |
|
78 | + $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
79 | + // To find a specific entry |
|
80 | + $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
81 | + // To find all recent entries with a given UID |
|
82 | + $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
83 | + // To find all recent entries with a given email address |
|
84 | + $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
85 | + // To find all recent entries with a give federated cloud id |
|
86 | + $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
87 | + // For the cleanup |
|
88 | + $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
89 | 89 | |
90 | - return $schema; |
|
91 | - } |
|
90 | + return $schema; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | } |
@@ -75,17 +75,17 @@ |
||
75 | 75 | ]); |
76 | 76 | $table->setPrimaryKey(['id']); |
77 | 77 | // To find all recent entries |
78 | - $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
78 | + $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME.'_actor_uid'); |
|
79 | 79 | // To find a specific entry |
80 | - $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
80 | + $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME.'_id_uid'); |
|
81 | 81 | // To find all recent entries with a given UID |
82 | - $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
82 | + $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME.'_uid'); |
|
83 | 83 | // To find all recent entries with a given email address |
84 | - $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
84 | + $table->addIndex(['email'], RecentContactMapper::TABLE_NAME.'_email'); |
|
85 | 85 | // To find all recent entries with a give federated cloud id |
86 | - $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
86 | + $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME.'_fed_id'); |
|
87 | 87 | // For the cleanup |
88 | - $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
88 | + $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME.'_last_contact'); |
|
89 | 89 | |
90 | 90 | return $schema; |
91 | 91 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\ContactsInteraction\\' => array($baseDir . '/../lib'), |
|
9 | + 'OCA\\ContactsInteraction\\' => array($baseDir.'/../lib'), |
|
10 | 10 | ); |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | private function findFileWithExtension($class, $ext) |
371 | 371 | { |
372 | 372 | // PSR-4 lookup |
373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
374 | 374 | |
375 | 375 | $first = $class[0]; |
376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
377 | 377 | $subPath = $class; |
378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
380 | - $search = $subPath . '\\'; |
|
380 | + $search = $subPath.'\\'; |
|
381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
385 | 385 | return $file; |
386 | 386 | } |
387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | |
392 | 392 | // PSR-4 fallback dirs |
393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
395 | 395 | return $file; |
396 | 396 | } |
397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
404 | 404 | } else { |
405 | 405 | // PEAR-like class name |
406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
411 | 411 | if (0 === strpos($class, $prefix)) { |
412 | 412 | foreach ($dirs as $dir) { |
413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
414 | 414 | return $file; |
415 | 415 | } |
416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | // PSR-0 fallback dirs |
422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
424 | 424 | return $file; |
425 | 425 | } |
426 | 426 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); |
36 | 36 | $configuration = $connection->getConfiguration(); |
37 | 37 | if (isset($configuration['ldap_agent_password']) && $configuration['ldap_agent_password'] !== '') { |
38 | - // hide password |
|
39 | - $configuration['ldap_agent_password'] = '**PASSWORD SET**'; |
|
38 | + // hide password |
|
39 | + $configuration['ldap_agent_password'] = '**PASSWORD SET**'; |
|
40 | 40 | } |
41 | 41 | \OC_JSON::success(['configuration' => $configuration]); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | \OC_JSON::checkAppEnabled('user_ldap'); |
13 | 13 | \OC_JSON::callCheck(); |
14 | 14 | |
15 | -$prefix = (string)$_POST['ldap_serverconfig_chooser']; |
|
15 | +$prefix = (string) $_POST['ldap_serverconfig_chooser']; |
|
16 | 16 | $ldapWrapper = new LDAP(); |
17 | 17 | $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); |
18 | 18 | $configuration = $connection->getConfiguration(); |
@@ -29,40 +29,40 @@ |
||
29 | 29 | * @deprecated 18.0.0 |
30 | 30 | */ |
31 | 31 | class TemplateManager { |
32 | - protected $templates = []; |
|
32 | + protected $templates = []; |
|
33 | 33 | |
34 | - public function registerTemplate($mimetype, $path) { |
|
35 | - $this->templates[$mimetype] = $path; |
|
36 | - } |
|
34 | + public function registerTemplate($mimetype, $path) { |
|
35 | + $this->templates[$mimetype] = $path; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * get the path of the template for a mimetype |
|
40 | - * |
|
41 | - * @deprecated 18.0.0 |
|
42 | - * @param string $mimetype |
|
43 | - * @return string|null |
|
44 | - */ |
|
45 | - public function getTemplatePath($mimetype) { |
|
46 | - if (isset($this->templates[$mimetype])) { |
|
47 | - return $this->templates[$mimetype]; |
|
48 | - } else { |
|
49 | - return null; |
|
50 | - } |
|
51 | - } |
|
38 | + /** |
|
39 | + * get the path of the template for a mimetype |
|
40 | + * |
|
41 | + * @deprecated 18.0.0 |
|
42 | + * @param string $mimetype |
|
43 | + * @return string|null |
|
44 | + */ |
|
45 | + public function getTemplatePath($mimetype) { |
|
46 | + if (isset($this->templates[$mimetype])) { |
|
47 | + return $this->templates[$mimetype]; |
|
48 | + } else { |
|
49 | + return null; |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * get the template content for a mimetype |
|
55 | - * |
|
56 | - * @deprecated 18.0.0 |
|
57 | - * @param string $mimetype |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function getTemplate($mimetype) { |
|
61 | - $path = $this->getTemplatePath($mimetype); |
|
62 | - if ($path) { |
|
63 | - return file_get_contents($path); |
|
64 | - } else { |
|
65 | - return ''; |
|
66 | - } |
|
67 | - } |
|
53 | + /** |
|
54 | + * get the template content for a mimetype |
|
55 | + * |
|
56 | + * @deprecated 18.0.0 |
|
57 | + * @param string $mimetype |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function getTemplate($mimetype) { |
|
61 | + $path = $this->getTemplatePath($mimetype); |
|
62 | + if ($path) { |
|
63 | + return file_get_contents($path); |
|
64 | + } else { |
|
65 | + return ''; |
|
66 | + } |
|
67 | + } |
|
68 | 68 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | */ |
52 | 52 | public function generate($name, $parameters = [], $absolute = false) { |
53 | 53 | asort($parameters); |
54 | - $key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($parameters)) . (int)$absolute; |
|
54 | + $key = $this->context->getHost().'#'.$this->context->getBaseUrl().$name.sha1(json_encode($parameters)).(int) $absolute; |
|
55 | 55 | $cachedKey = $this->cache->get($key); |
56 | 56 | if ($cachedKey) { |
57 | 57 | return $cachedKey; |
@@ -17,41 +17,41 @@ |
||
17 | 17 | use Psr\Log\LoggerInterface; |
18 | 18 | |
19 | 19 | class CachingRouter extends Router { |
20 | - protected ICache $cache; |
|
20 | + protected ICache $cache; |
|
21 | 21 | |
22 | - public function __construct( |
|
23 | - ICacheFactory $cacheFactory, |
|
24 | - LoggerInterface $logger, |
|
25 | - IRequest $request, |
|
26 | - IConfig $config, |
|
27 | - IEventLogger $eventLogger, |
|
28 | - ContainerInterface $container, |
|
29 | - IAppManager $appManager, |
|
30 | - ) { |
|
31 | - $this->cache = $cacheFactory->createLocal('route'); |
|
32 | - parent::__construct($logger, $request, $config, $eventLogger, $container, $appManager); |
|
33 | - } |
|
22 | + public function __construct( |
|
23 | + ICacheFactory $cacheFactory, |
|
24 | + LoggerInterface $logger, |
|
25 | + IRequest $request, |
|
26 | + IConfig $config, |
|
27 | + IEventLogger $eventLogger, |
|
28 | + ContainerInterface $container, |
|
29 | + IAppManager $appManager, |
|
30 | + ) { |
|
31 | + $this->cache = $cacheFactory->createLocal('route'); |
|
32 | + parent::__construct($logger, $request, $config, $eventLogger, $container, $appManager); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Generate url based on $name and $parameters |
|
37 | - * |
|
38 | - * @param string $name Name of the route to use. |
|
39 | - * @param array $parameters Parameters for the route |
|
40 | - * @param bool $absolute |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function generate($name, $parameters = [], $absolute = false) { |
|
44 | - asort($parameters); |
|
45 | - $key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($parameters)) . (int)$absolute; |
|
46 | - $cachedKey = $this->cache->get($key); |
|
47 | - if ($cachedKey) { |
|
48 | - return $cachedKey; |
|
49 | - } else { |
|
50 | - $url = parent::generate($name, $parameters, $absolute); |
|
51 | - if ($url) { |
|
52 | - $this->cache->set($key, $url, 3600); |
|
53 | - } |
|
54 | - return $url; |
|
55 | - } |
|
56 | - } |
|
35 | + /** |
|
36 | + * Generate url based on $name and $parameters |
|
37 | + * |
|
38 | + * @param string $name Name of the route to use. |
|
39 | + * @param array $parameters Parameters for the route |
|
40 | + * @param bool $absolute |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function generate($name, $parameters = [], $absolute = false) { |
|
44 | + asort($parameters); |
|
45 | + $key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($parameters)) . (int)$absolute; |
|
46 | + $cachedKey = $this->cache->get($key); |
|
47 | + if ($cachedKey) { |
|
48 | + return $cachedKey; |
|
49 | + } else { |
|
50 | + $url = parent::generate($name, $parameters, $absolute); |
|
51 | + if ($url) { |
|
52 | + $this->cache->set($key, $url, 3600); |
|
53 | + } |
|
54 | + return $url; |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | $uid = $publicKeyCredentialUserEntity->getId(); |
57 | 57 | $entities = $this->credentialMapper->findAllForUid($uid); |
58 | 58 | |
59 | - return array_map(function (PublicKeyCredentialEntity $entity) { |
|
59 | + return array_map(function(PublicKeyCredentialEntity $entity) { |
|
60 | 60 | return $entity->toPublicKeyCredentialSource(); |
61 | 61 | }, $entities); |
62 | 62 | } |
@@ -16,66 +16,66 @@ |
||
16 | 16 | use Webauthn\PublicKeyCredentialUserEntity; |
17 | 17 | |
18 | 18 | class CredentialRepository implements PublicKeyCredentialSourceRepository { |
19 | - /** @var PublicKeyCredentialMapper */ |
|
20 | - private $credentialMapper; |
|
21 | - |
|
22 | - public function __construct(PublicKeyCredentialMapper $credentialMapper) { |
|
23 | - $this->credentialMapper = $credentialMapper; |
|
24 | - } |
|
25 | - |
|
26 | - public function findOneByCredentialId(string $publicKeyCredentialId): ?PublicKeyCredentialSource { |
|
27 | - try { |
|
28 | - $entity = $this->credentialMapper->findOneByCredentialId($publicKeyCredentialId); |
|
29 | - return $entity->toPublicKeyCredentialSource(); |
|
30 | - } catch (IMapperException $e) { |
|
31 | - return null; |
|
32 | - } |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * @return PublicKeyCredentialSource[] |
|
37 | - */ |
|
38 | - public function findAllForUserEntity(PublicKeyCredentialUserEntity $publicKeyCredentialUserEntity): array { |
|
39 | - $uid = $publicKeyCredentialUserEntity->getId(); |
|
40 | - $entities = $this->credentialMapper->findAllForUid($uid); |
|
41 | - |
|
42 | - return array_map(function (PublicKeyCredentialEntity $entity) { |
|
43 | - return $entity->toPublicKeyCredentialSource(); |
|
44 | - }, $entities); |
|
45 | - } |
|
46 | - |
|
47 | - public function saveAndReturnCredentialSource(PublicKeyCredentialSource $publicKeyCredentialSource, ?string $name = null, bool $userVerification = false): PublicKeyCredentialEntity { |
|
48 | - $oldEntity = null; |
|
49 | - |
|
50 | - try { |
|
51 | - $oldEntity = $this->credentialMapper->findOneByCredentialId($publicKeyCredentialSource->getPublicKeyCredentialId()); |
|
52 | - } catch (IMapperException $e) { |
|
53 | - } |
|
54 | - |
|
55 | - $defaultName = false; |
|
56 | - if ($name === null) { |
|
57 | - $defaultName = true; |
|
58 | - $name = 'default'; |
|
59 | - } |
|
60 | - |
|
61 | - $entity = PublicKeyCredentialEntity::fromPublicKeyCrendentialSource($name, $publicKeyCredentialSource, $userVerification); |
|
62 | - |
|
63 | - if ($oldEntity) { |
|
64 | - $entity->setId($oldEntity->getId()); |
|
65 | - if ($defaultName) { |
|
66 | - $entity->setName($oldEntity->getName()); |
|
67 | - } |
|
68 | - |
|
69 | - // Don't downgrade UV just because it was skipped during a login due to another key |
|
70 | - if ($oldEntity->getUserVerification()) { |
|
71 | - $entity->setUserVerification(true); |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - return $this->credentialMapper->insertOrUpdate($entity); |
|
76 | - } |
|
77 | - |
|
78 | - public function saveCredentialSource(PublicKeyCredentialSource $publicKeyCredentialSource, ?string $name = null): void { |
|
79 | - $this->saveAndReturnCredentialSource($publicKeyCredentialSource, $name); |
|
80 | - } |
|
19 | + /** @var PublicKeyCredentialMapper */ |
|
20 | + private $credentialMapper; |
|
21 | + |
|
22 | + public function __construct(PublicKeyCredentialMapper $credentialMapper) { |
|
23 | + $this->credentialMapper = $credentialMapper; |
|
24 | + } |
|
25 | + |
|
26 | + public function findOneByCredentialId(string $publicKeyCredentialId): ?PublicKeyCredentialSource { |
|
27 | + try { |
|
28 | + $entity = $this->credentialMapper->findOneByCredentialId($publicKeyCredentialId); |
|
29 | + return $entity->toPublicKeyCredentialSource(); |
|
30 | + } catch (IMapperException $e) { |
|
31 | + return null; |
|
32 | + } |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @return PublicKeyCredentialSource[] |
|
37 | + */ |
|
38 | + public function findAllForUserEntity(PublicKeyCredentialUserEntity $publicKeyCredentialUserEntity): array { |
|
39 | + $uid = $publicKeyCredentialUserEntity->getId(); |
|
40 | + $entities = $this->credentialMapper->findAllForUid($uid); |
|
41 | + |
|
42 | + return array_map(function (PublicKeyCredentialEntity $entity) { |
|
43 | + return $entity->toPublicKeyCredentialSource(); |
|
44 | + }, $entities); |
|
45 | + } |
|
46 | + |
|
47 | + public function saveAndReturnCredentialSource(PublicKeyCredentialSource $publicKeyCredentialSource, ?string $name = null, bool $userVerification = false): PublicKeyCredentialEntity { |
|
48 | + $oldEntity = null; |
|
49 | + |
|
50 | + try { |
|
51 | + $oldEntity = $this->credentialMapper->findOneByCredentialId($publicKeyCredentialSource->getPublicKeyCredentialId()); |
|
52 | + } catch (IMapperException $e) { |
|
53 | + } |
|
54 | + |
|
55 | + $defaultName = false; |
|
56 | + if ($name === null) { |
|
57 | + $defaultName = true; |
|
58 | + $name = 'default'; |
|
59 | + } |
|
60 | + |
|
61 | + $entity = PublicKeyCredentialEntity::fromPublicKeyCrendentialSource($name, $publicKeyCredentialSource, $userVerification); |
|
62 | + |
|
63 | + if ($oldEntity) { |
|
64 | + $entity->setId($oldEntity->getId()); |
|
65 | + if ($defaultName) { |
|
66 | + $entity->setName($oldEntity->getName()); |
|
67 | + } |
|
68 | + |
|
69 | + // Don't downgrade UV just because it was skipped during a login due to another key |
|
70 | + if ($oldEntity->getUserVerification()) { |
|
71 | + $entity->setUserVerification(true); |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + return $this->credentialMapper->insertOrUpdate($entity); |
|
76 | + } |
|
77 | + |
|
78 | + public function saveCredentialSource(PublicKeyCredentialSource $publicKeyCredentialSource, ?string $name = null): void { |
|
79 | + $this->saveAndReturnCredentialSource($publicKeyCredentialSource, $name); |
|
80 | + } |
|
81 | 81 | } |