@@ -35,16 +35,16 @@ |
||
35 | 35 | use OCP\AppFramework\Bootstrap\IRegistrationContext; |
36 | 36 | |
37 | 37 | class Application extends App implements IBootstrap { |
38 | - public const APP_ID = 'sharebymail'; |
|
38 | + public const APP_ID = 'sharebymail'; |
|
39 | 39 | |
40 | - public function __construct() { |
|
41 | - parent::__construct(self::APP_ID); |
|
42 | - } |
|
40 | + public function __construct() { |
|
41 | + parent::__construct(self::APP_ID); |
|
42 | + } |
|
43 | 43 | |
44 | - public function register(IRegistrationContext $context): void { |
|
45 | - $context->registerCapability(Capabilities::class); |
|
46 | - } |
|
44 | + public function register(IRegistrationContext $context): void { |
|
45 | + $context->registerCapability(Capabilities::class); |
|
46 | + } |
|
47 | 47 | |
48 | - public function boot(IBootContext $context): void { |
|
49 | - } |
|
48 | + public function boot(IBootContext $context): void { |
|
49 | + } |
|
50 | 50 | } |
@@ -32,17 +32,17 @@ |
||
32 | 32 | * @since 20.0.0 |
33 | 33 | */ |
34 | 34 | interface IDeferrableApp extends IApp { |
35 | - /** |
|
36 | - * Start deferring notifications until `flush()` is called |
|
37 | - * |
|
38 | - * @since 20.0.0 |
|
39 | - */ |
|
40 | - public function defer(): void; |
|
35 | + /** |
|
36 | + * Start deferring notifications until `flush()` is called |
|
37 | + * |
|
38 | + * @since 20.0.0 |
|
39 | + */ |
|
40 | + public function defer(): void; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Send all deferred notifications that have been stored since `defer()` was called |
|
44 | - * |
|
45 | - * @since 20.0.0 |
|
46 | - */ |
|
47 | - public function flush(): void; |
|
42 | + /** |
|
43 | + * Send all deferred notifications that have been stored since `defer()` was called |
|
44 | + * |
|
45 | + * @since 20.0.0 |
|
46 | + */ |
|
47 | + public function flush(): void; |
|
48 | 48 | } |
@@ -34,67 +34,67 @@ |
||
34 | 34 | use Sabre\HTTP\RequestInterface; |
35 | 35 | |
36 | 36 | class LockPlugin extends ServerPlugin { |
37 | - /** |
|
38 | - * Reference to main server object |
|
39 | - * |
|
40 | - * @var \Sabre\DAV\Server |
|
41 | - */ |
|
42 | - private $server; |
|
37 | + /** |
|
38 | + * Reference to main server object |
|
39 | + * |
|
40 | + * @var \Sabre\DAV\Server |
|
41 | + */ |
|
42 | + private $server; |
|
43 | 43 | |
44 | - /** |
|
45 | - * State of the lock |
|
46 | - * |
|
47 | - * @var bool |
|
48 | - */ |
|
49 | - private $isLocked; |
|
44 | + /** |
|
45 | + * State of the lock |
|
46 | + * |
|
47 | + * @var bool |
|
48 | + */ |
|
49 | + private $isLocked; |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inheritdoc} |
|
53 | - */ |
|
54 | - public function initialize(\Sabre\DAV\Server $server) { |
|
55 | - $this->server = $server; |
|
56 | - $this->server->on('beforeMethod:*', [$this, 'getLock'], 50); |
|
57 | - $this->server->on('afterMethod:*', [$this, 'releaseLock'], 50); |
|
58 | - $this->isLocked = false; |
|
59 | - } |
|
51 | + /** |
|
52 | + * {@inheritdoc} |
|
53 | + */ |
|
54 | + public function initialize(\Sabre\DAV\Server $server) { |
|
55 | + $this->server = $server; |
|
56 | + $this->server->on('beforeMethod:*', [$this, 'getLock'], 50); |
|
57 | + $this->server->on('afterMethod:*', [$this, 'releaseLock'], 50); |
|
58 | + $this->isLocked = false; |
|
59 | + } |
|
60 | 60 | |
61 | - public function getLock(RequestInterface $request) { |
|
62 | - // we can't listen on 'beforeMethod:PUT' due to order of operations with setting up the tree |
|
63 | - // so instead we limit ourselves to the PUT method manually |
|
64 | - if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) { |
|
65 | - return; |
|
66 | - } |
|
67 | - try { |
|
68 | - $node = $this->server->tree->getNodeForPath($request->getPath()); |
|
69 | - } catch (NotFound $e) { |
|
70 | - return; |
|
71 | - } |
|
72 | - if ($node instanceof Node) { |
|
73 | - try { |
|
74 | - $node->acquireLock(ILockingProvider::LOCK_SHARED); |
|
75 | - } catch (LockedException $e) { |
|
76 | - throw new FileLocked($e->getMessage(), $e->getCode(), $e); |
|
77 | - } |
|
78 | - $this->isLocked = true; |
|
79 | - } |
|
80 | - } |
|
61 | + public function getLock(RequestInterface $request) { |
|
62 | + // we can't listen on 'beforeMethod:PUT' due to order of operations with setting up the tree |
|
63 | + // so instead we limit ourselves to the PUT method manually |
|
64 | + if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) { |
|
65 | + return; |
|
66 | + } |
|
67 | + try { |
|
68 | + $node = $this->server->tree->getNodeForPath($request->getPath()); |
|
69 | + } catch (NotFound $e) { |
|
70 | + return; |
|
71 | + } |
|
72 | + if ($node instanceof Node) { |
|
73 | + try { |
|
74 | + $node->acquireLock(ILockingProvider::LOCK_SHARED); |
|
75 | + } catch (LockedException $e) { |
|
76 | + throw new FileLocked($e->getMessage(), $e->getCode(), $e); |
|
77 | + } |
|
78 | + $this->isLocked = true; |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - public function releaseLock(RequestInterface $request) { |
|
83 | - // don't try to release the lock if we never locked one |
|
84 | - if ($this->isLocked === false) { |
|
85 | - return; |
|
86 | - } |
|
87 | - if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) { |
|
88 | - return; |
|
89 | - } |
|
90 | - try { |
|
91 | - $node = $this->server->tree->getNodeForPath($request->getPath()); |
|
92 | - } catch (NotFound $e) { |
|
93 | - return; |
|
94 | - } |
|
95 | - if ($node instanceof Node) { |
|
96 | - $node->releaseLock(ILockingProvider::LOCK_SHARED); |
|
97 | - $this->isLocked = false; |
|
98 | - } |
|
99 | - } |
|
82 | + public function releaseLock(RequestInterface $request) { |
|
83 | + // don't try to release the lock if we never locked one |
|
84 | + if ($this->isLocked === false) { |
|
85 | + return; |
|
86 | + } |
|
87 | + if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) { |
|
88 | + return; |
|
89 | + } |
|
90 | + try { |
|
91 | + $node = $this->server->tree->getNodeForPath($request->getPath()); |
|
92 | + } catch (NotFound $e) { |
|
93 | + return; |
|
94 | + } |
|
95 | + if ($node instanceof Node) { |
|
96 | + $node->releaseLock(ILockingProvider::LOCK_SHARED); |
|
97 | + $this->isLocked = false; |
|
98 | + } |
|
99 | + } |
|
100 | 100 | } |
@@ -33,51 +33,51 @@ |
||
33 | 33 | |
34 | 34 | class Version1010Date20200630191302 extends SimpleMigrationStep { |
35 | 35 | |
36 | - /** |
|
37 | - * @param IOutput $output |
|
38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | - * @param array $options |
|
40 | - * @return null|ISchemaWrapper |
|
41 | - */ |
|
42 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
43 | - /** @var ISchemaWrapper $schema */ |
|
44 | - $schema = $schemaClosure(); |
|
36 | + /** |
|
37 | + * @param IOutput $output |
|
38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | + * @param array $options |
|
40 | + * @return null|ISchemaWrapper |
|
41 | + */ |
|
42 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
43 | + /** @var ISchemaWrapper $schema */ |
|
44 | + $schema = $schemaClosure(); |
|
45 | 45 | |
46 | - if (!$schema->hasTable('trusted_servers')) { |
|
47 | - $table = $schema->createTable('trusted_servers'); |
|
48 | - $table->addColumn('id', Types::INTEGER, [ |
|
49 | - 'autoincrement' => true, |
|
50 | - 'notnull' => true, |
|
51 | - 'length' => 4, |
|
52 | - ]); |
|
53 | - $table->addColumn('url', Types::STRING, [ |
|
54 | - 'notnull' => true, |
|
55 | - 'length' => 512, |
|
56 | - ]); |
|
57 | - $table->addColumn('url_hash', Types::STRING, [ |
|
58 | - 'notnull' => true, |
|
59 | - 'default' => '', |
|
60 | - ]); |
|
61 | - $table->addColumn('token', Types::STRING, [ |
|
62 | - 'notnull' => false, |
|
63 | - 'length' => 128, |
|
64 | - ]); |
|
65 | - $table->addColumn('shared_secret', Types::STRING, [ |
|
66 | - 'notnull' => false, |
|
67 | - 'length' => 256, |
|
68 | - ]); |
|
69 | - $table->addColumn('status', Types::INTEGER, [ |
|
70 | - 'notnull' => true, |
|
71 | - 'length' => 4, |
|
72 | - 'default' => 2, |
|
73 | - ]); |
|
74 | - $table->addColumn('sync_token', Types::STRING, [ |
|
75 | - 'notnull' => false, |
|
76 | - 'length' => 512, |
|
77 | - ]); |
|
78 | - $table->setPrimaryKey(['id']); |
|
79 | - $table->addUniqueIndex(['url_hash'], 'url_hash'); |
|
80 | - } |
|
81 | - return $schema; |
|
82 | - } |
|
46 | + if (!$schema->hasTable('trusted_servers')) { |
|
47 | + $table = $schema->createTable('trusted_servers'); |
|
48 | + $table->addColumn('id', Types::INTEGER, [ |
|
49 | + 'autoincrement' => true, |
|
50 | + 'notnull' => true, |
|
51 | + 'length' => 4, |
|
52 | + ]); |
|
53 | + $table->addColumn('url', Types::STRING, [ |
|
54 | + 'notnull' => true, |
|
55 | + 'length' => 512, |
|
56 | + ]); |
|
57 | + $table->addColumn('url_hash', Types::STRING, [ |
|
58 | + 'notnull' => true, |
|
59 | + 'default' => '', |
|
60 | + ]); |
|
61 | + $table->addColumn('token', Types::STRING, [ |
|
62 | + 'notnull' => false, |
|
63 | + 'length' => 128, |
|
64 | + ]); |
|
65 | + $table->addColumn('shared_secret', Types::STRING, [ |
|
66 | + 'notnull' => false, |
|
67 | + 'length' => 256, |
|
68 | + ]); |
|
69 | + $table->addColumn('status', Types::INTEGER, [ |
|
70 | + 'notnull' => true, |
|
71 | + 'length' => 4, |
|
72 | + 'default' => 2, |
|
73 | + ]); |
|
74 | + $table->addColumn('sync_token', Types::STRING, [ |
|
75 | + 'notnull' => false, |
|
76 | + 'length' => 512, |
|
77 | + ]); |
|
78 | + $table->setPrimaryKey(['id']); |
|
79 | + $table->addUniqueIndex(['url_hash'], 'url_hash'); |
|
80 | + } |
|
81 | + return $schema; |
|
82 | + } |
|
83 | 83 | } |
@@ -33,16 +33,16 @@ |
||
33 | 33 | use OCP\Contacts\Events\ContactInteractedWithEvent; |
34 | 34 | |
35 | 35 | class Application extends App implements IBootstrap { |
36 | - public const APP_ID = 'contactsinteraction'; |
|
36 | + public const APP_ID = 'contactsinteraction'; |
|
37 | 37 | |
38 | - public function __construct() { |
|
39 | - parent::__construct(self::APP_ID); |
|
40 | - } |
|
38 | + public function __construct() { |
|
39 | + parent::__construct(self::APP_ID); |
|
40 | + } |
|
41 | 41 | |
42 | - public function register(IRegistrationContext $context): void { |
|
43 | - $context->registerEventListener(ContactInteractedWithEvent::class, ContactInteractionListener::class); |
|
44 | - } |
|
42 | + public function register(IRegistrationContext $context): void { |
|
43 | + $context->registerEventListener(ContactInteractedWithEvent::class, ContactInteractionListener::class); |
|
44 | + } |
|
45 | 45 | |
46 | - public function boot(IBootContext $context): void { |
|
47 | - } |
|
46 | + public function boot(IBootContext $context): void { |
|
47 | + } |
|
48 | 48 | } |
@@ -33,84 +33,84 @@ |
||
33 | 33 | * Delete all file entries that have no matching entries in the storage table. |
34 | 34 | */ |
35 | 35 | class DeleteOrphanedFiles extends Command { |
36 | - public const CHUNK_SIZE = 200; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var IDBConnection |
|
40 | - */ |
|
41 | - protected $connection; |
|
42 | - |
|
43 | - public function __construct(IDBConnection $connection) { |
|
44 | - $this->connection = $connection; |
|
45 | - parent::__construct(); |
|
46 | - } |
|
47 | - |
|
48 | - protected function configure() { |
|
49 | - $this |
|
50 | - ->setName('files:cleanup') |
|
51 | - ->setDescription('cleanup filecache'); |
|
52 | - } |
|
53 | - |
|
54 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
55 | - $deletedEntries = 0; |
|
56 | - |
|
57 | - $query = $this->connection->getQueryBuilder(); |
|
58 | - $query->select('fc.fileid') |
|
59 | - ->from('filecache', 'fc') |
|
60 | - ->where($query->expr()->isNull('s.numeric_id')) |
|
61 | - ->leftJoin('fc', 'storages', 's', $query->expr()->eq('fc.storage', 's.numeric_id')) |
|
62 | - ->setMaxResults(self::CHUNK_SIZE); |
|
63 | - |
|
64 | - $deleteQuery = $this->connection->getQueryBuilder(); |
|
65 | - $deleteQuery->delete('filecache') |
|
66 | - ->where($deleteQuery->expr()->eq('fileid', $deleteQuery->createParameter('objectid'))); |
|
67 | - |
|
68 | - $deletedInLastChunk = self::CHUNK_SIZE; |
|
69 | - while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
70 | - $deletedInLastChunk = 0; |
|
71 | - $result = $query->execute(); |
|
72 | - while ($row = $result->fetch()) { |
|
73 | - $deletedInLastChunk++; |
|
74 | - $deletedEntries += $deleteQuery->setParameter('objectid', (int) $row['fileid']) |
|
75 | - ->execute(); |
|
76 | - } |
|
77 | - $result->closeCursor(); |
|
78 | - } |
|
79 | - |
|
80 | - $output->writeln("$deletedEntries orphaned file cache entries deleted"); |
|
81 | - |
|
82 | - $deletedMounts = $this->cleanupOrphanedMounts(); |
|
83 | - $output->writeln("$deletedMounts orphaned mount entries deleted"); |
|
84 | - return 0; |
|
85 | - } |
|
86 | - |
|
87 | - private function cleanupOrphanedMounts() { |
|
88 | - $deletedEntries = 0; |
|
89 | - |
|
90 | - $query = $this->connection->getQueryBuilder(); |
|
91 | - $query->select('m.storage_id') |
|
92 | - ->from('mounts', 'm') |
|
93 | - ->where($query->expr()->isNull('s.numeric_id')) |
|
94 | - ->leftJoin('m', 'storages', 's', $query->expr()->eq('m.storage_id', 's.numeric_id')) |
|
95 | - ->groupBy('storage_id') |
|
96 | - ->setMaxResults(self::CHUNK_SIZE); |
|
97 | - |
|
98 | - $deleteQuery = $this->connection->getQueryBuilder(); |
|
99 | - $deleteQuery->delete('mounts') |
|
100 | - ->where($deleteQuery->expr()->eq('storage_id', $deleteQuery->createParameter('storageid'))); |
|
101 | - |
|
102 | - $deletedInLastChunk = self::CHUNK_SIZE; |
|
103 | - while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
104 | - $deletedInLastChunk = 0; |
|
105 | - $result = $query->execute(); |
|
106 | - while ($row = $result->fetch()) { |
|
107 | - $deletedInLastChunk++; |
|
108 | - $deletedEntries += $deleteQuery->setParameter('storageid', (int) $row['storage_id']) |
|
109 | - ->execute(); |
|
110 | - } |
|
111 | - $result->closeCursor(); |
|
112 | - } |
|
113 | - |
|
114 | - return $deletedEntries; |
|
115 | - } |
|
36 | + public const CHUNK_SIZE = 200; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var IDBConnection |
|
40 | + */ |
|
41 | + protected $connection; |
|
42 | + |
|
43 | + public function __construct(IDBConnection $connection) { |
|
44 | + $this->connection = $connection; |
|
45 | + parent::__construct(); |
|
46 | + } |
|
47 | + |
|
48 | + protected function configure() { |
|
49 | + $this |
|
50 | + ->setName('files:cleanup') |
|
51 | + ->setDescription('cleanup filecache'); |
|
52 | + } |
|
53 | + |
|
54 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
55 | + $deletedEntries = 0; |
|
56 | + |
|
57 | + $query = $this->connection->getQueryBuilder(); |
|
58 | + $query->select('fc.fileid') |
|
59 | + ->from('filecache', 'fc') |
|
60 | + ->where($query->expr()->isNull('s.numeric_id')) |
|
61 | + ->leftJoin('fc', 'storages', 's', $query->expr()->eq('fc.storage', 's.numeric_id')) |
|
62 | + ->setMaxResults(self::CHUNK_SIZE); |
|
63 | + |
|
64 | + $deleteQuery = $this->connection->getQueryBuilder(); |
|
65 | + $deleteQuery->delete('filecache') |
|
66 | + ->where($deleteQuery->expr()->eq('fileid', $deleteQuery->createParameter('objectid'))); |
|
67 | + |
|
68 | + $deletedInLastChunk = self::CHUNK_SIZE; |
|
69 | + while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
70 | + $deletedInLastChunk = 0; |
|
71 | + $result = $query->execute(); |
|
72 | + while ($row = $result->fetch()) { |
|
73 | + $deletedInLastChunk++; |
|
74 | + $deletedEntries += $deleteQuery->setParameter('objectid', (int) $row['fileid']) |
|
75 | + ->execute(); |
|
76 | + } |
|
77 | + $result->closeCursor(); |
|
78 | + } |
|
79 | + |
|
80 | + $output->writeln("$deletedEntries orphaned file cache entries deleted"); |
|
81 | + |
|
82 | + $deletedMounts = $this->cleanupOrphanedMounts(); |
|
83 | + $output->writeln("$deletedMounts orphaned mount entries deleted"); |
|
84 | + return 0; |
|
85 | + } |
|
86 | + |
|
87 | + private function cleanupOrphanedMounts() { |
|
88 | + $deletedEntries = 0; |
|
89 | + |
|
90 | + $query = $this->connection->getQueryBuilder(); |
|
91 | + $query->select('m.storage_id') |
|
92 | + ->from('mounts', 'm') |
|
93 | + ->where($query->expr()->isNull('s.numeric_id')) |
|
94 | + ->leftJoin('m', 'storages', 's', $query->expr()->eq('m.storage_id', 's.numeric_id')) |
|
95 | + ->groupBy('storage_id') |
|
96 | + ->setMaxResults(self::CHUNK_SIZE); |
|
97 | + |
|
98 | + $deleteQuery = $this->connection->getQueryBuilder(); |
|
99 | + $deleteQuery->delete('mounts') |
|
100 | + ->where($deleteQuery->expr()->eq('storage_id', $deleteQuery->createParameter('storageid'))); |
|
101 | + |
|
102 | + $deletedInLastChunk = self::CHUNK_SIZE; |
|
103 | + while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
104 | + $deletedInLastChunk = 0; |
|
105 | + $result = $query->execute(); |
|
106 | + while ($row = $result->fetch()) { |
|
107 | + $deletedInLastChunk++; |
|
108 | + $deletedEntries += $deleteQuery->setParameter('storageid', (int) $row['storage_id']) |
|
109 | + ->execute(); |
|
110 | + } |
|
111 | + $result->closeCursor(); |
|
112 | + } |
|
113 | + |
|
114 | + return $deletedEntries; |
|
115 | + } |
|
116 | 116 | } |
@@ -33,16 +33,16 @@ |
||
33 | 33 | use OCP\AppFramework\Bootstrap\IRegistrationContext; |
34 | 34 | |
35 | 35 | class Application extends App implements IBootstrap { |
36 | - public const APP_ID = 'cloud_federation_api'; |
|
36 | + public const APP_ID = 'cloud_federation_api'; |
|
37 | 37 | |
38 | - public function __construct() { |
|
39 | - parent::__construct(self::APP_ID); |
|
40 | - } |
|
38 | + public function __construct() { |
|
39 | + parent::__construct(self::APP_ID); |
|
40 | + } |
|
41 | 41 | |
42 | - public function register(IRegistrationContext $context): void { |
|
43 | - $context->registerCapability(Capabilities::class); |
|
44 | - } |
|
42 | + public function register(IRegistrationContext $context): void { |
|
43 | + $context->registerCapability(Capabilities::class); |
|
44 | + } |
|
45 | 45 | |
46 | - public function boot(IBootContext $context): void { |
|
47 | - } |
|
46 | + public function boot(IBootContext $context): void { |
|
47 | + } |
|
48 | 48 | } |
@@ -32,72 +32,72 @@ |
||
32 | 32 | * Legacy compatibility for OCA\Files_External\MountConfig::registerBackend() |
33 | 33 | */ |
34 | 34 | class LegacyBackend extends Backend { |
35 | - use LegacyDependencyCheckPolyfill { |
|
36 | - LegacyDependencyCheckPolyfill::checkDependencies as doCheckDependencies; |
|
37 | - } |
|
35 | + use LegacyDependencyCheckPolyfill { |
|
36 | + LegacyDependencyCheckPolyfill::checkDependencies as doCheckDependencies; |
|
37 | + } |
|
38 | 38 | |
39 | - /** @var bool */ |
|
40 | - protected $hasDependencies = false; |
|
39 | + /** @var bool */ |
|
40 | + protected $hasDependencies = false; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param string $class |
|
44 | - * @param array $definition |
|
45 | - * @param Builtin $authMechanism |
|
46 | - */ |
|
47 | - public function __construct($class, array $definition, Builtin $authMechanism) { |
|
48 | - $this |
|
49 | - ->setIdentifier($class) |
|
50 | - ->setStorageClass($class) |
|
51 | - ->setText($definition['backend']) |
|
52 | - ->addAuthScheme(Builtin::SCHEME_BUILTIN) |
|
53 | - ->setLegacyAuthMechanism($authMechanism) |
|
54 | - ; |
|
42 | + /** |
|
43 | + * @param string $class |
|
44 | + * @param array $definition |
|
45 | + * @param Builtin $authMechanism |
|
46 | + */ |
|
47 | + public function __construct($class, array $definition, Builtin $authMechanism) { |
|
48 | + $this |
|
49 | + ->setIdentifier($class) |
|
50 | + ->setStorageClass($class) |
|
51 | + ->setText($definition['backend']) |
|
52 | + ->addAuthScheme(Builtin::SCHEME_BUILTIN) |
|
53 | + ->setLegacyAuthMechanism($authMechanism) |
|
54 | + ; |
|
55 | 55 | |
56 | - foreach ($definition['configuration'] as $name => $placeholder) { |
|
57 | - $flags = DefinitionParameter::FLAG_NONE; |
|
58 | - $type = DefinitionParameter::VALUE_TEXT; |
|
59 | - if ($placeholder[0] === '&') { |
|
60 | - $flags = DefinitionParameter::FLAG_OPTIONAL; |
|
61 | - $placeholder = substr($placeholder, 1); |
|
62 | - } |
|
63 | - switch ($placeholder[0]) { |
|
64 | - case '!': |
|
65 | - $type = DefinitionParameter::VALUE_BOOLEAN; |
|
66 | - $placeholder = substr($placeholder, 1); |
|
67 | - break; |
|
68 | - case '*': |
|
69 | - $type = DefinitionParameter::VALUE_PASSWORD; |
|
70 | - $placeholder = substr($placeholder, 1); |
|
71 | - break; |
|
72 | - case '#': |
|
73 | - $type = DefinitionParameter::VALUE_HIDDEN; |
|
74 | - $placeholder = substr($placeholder, 1); |
|
75 | - break; |
|
76 | - } |
|
77 | - $this->addParameter((new DefinitionParameter($name, $placeholder)) |
|
78 | - ->setType($type) |
|
79 | - ->setFlags($flags) |
|
80 | - ); |
|
81 | - } |
|
56 | + foreach ($definition['configuration'] as $name => $placeholder) { |
|
57 | + $flags = DefinitionParameter::FLAG_NONE; |
|
58 | + $type = DefinitionParameter::VALUE_TEXT; |
|
59 | + if ($placeholder[0] === '&') { |
|
60 | + $flags = DefinitionParameter::FLAG_OPTIONAL; |
|
61 | + $placeholder = substr($placeholder, 1); |
|
62 | + } |
|
63 | + switch ($placeholder[0]) { |
|
64 | + case '!': |
|
65 | + $type = DefinitionParameter::VALUE_BOOLEAN; |
|
66 | + $placeholder = substr($placeholder, 1); |
|
67 | + break; |
|
68 | + case '*': |
|
69 | + $type = DefinitionParameter::VALUE_PASSWORD; |
|
70 | + $placeholder = substr($placeholder, 1); |
|
71 | + break; |
|
72 | + case '#': |
|
73 | + $type = DefinitionParameter::VALUE_HIDDEN; |
|
74 | + $placeholder = substr($placeholder, 1); |
|
75 | + break; |
|
76 | + } |
|
77 | + $this->addParameter((new DefinitionParameter($name, $placeholder)) |
|
78 | + ->setType($type) |
|
79 | + ->setFlags($flags) |
|
80 | + ); |
|
81 | + } |
|
82 | 82 | |
83 | - if (isset($definition['priority'])) { |
|
84 | - $this->setPriority($definition['priority']); |
|
85 | - } |
|
86 | - if (isset($definition['custom'])) { |
|
87 | - $this->addCustomJs($definition['custom']); |
|
88 | - } |
|
89 | - if (isset($definition['has_dependencies']) && $definition['has_dependencies']) { |
|
90 | - $this->hasDependencies = true; |
|
91 | - } |
|
92 | - } |
|
83 | + if (isset($definition['priority'])) { |
|
84 | + $this->setPriority($definition['priority']); |
|
85 | + } |
|
86 | + if (isset($definition['custom'])) { |
|
87 | + $this->addCustomJs($definition['custom']); |
|
88 | + } |
|
89 | + if (isset($definition['has_dependencies']) && $definition['has_dependencies']) { |
|
90 | + $this->hasDependencies = true; |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return MissingDependency[] |
|
96 | - */ |
|
97 | - public function checkDependencies() { |
|
98 | - if ($this->hasDependencies) { |
|
99 | - return $this->doCheckDependencies(); |
|
100 | - } |
|
101 | - return []; |
|
102 | - } |
|
94 | + /** |
|
95 | + * @return MissingDependency[] |
|
96 | + */ |
|
97 | + public function checkDependencies() { |
|
98 | + if ($this->hasDependencies) { |
|
99 | + return $this->doCheckDependencies(); |
|
100 | + } |
|
101 | + return []; |
|
102 | + } |
|
103 | 103 | } |
@@ -40,79 +40,79 @@ |
||
40 | 40 | |
41 | 41 | class Authtokens implements ISettings { |
42 | 42 | |
43 | - /** @var IAuthTokenProvider */ |
|
44 | - private $tokenProvider; |
|
45 | - |
|
46 | - /** @var ISession */ |
|
47 | - private $session; |
|
48 | - |
|
49 | - /** @var IInitialState */ |
|
50 | - private $initialState; |
|
51 | - |
|
52 | - /** @var string|null */ |
|
53 | - private $uid; |
|
54 | - |
|
55 | - /** @var IUserSession */ |
|
56 | - private $userSession; |
|
57 | - |
|
58 | - public function __construct(IAuthTokenProvider $tokenProvider, |
|
59 | - ISession $session, |
|
60 | - IUserSession $userSession, |
|
61 | - IInitialState $initialState, |
|
62 | - ?string $UserId) { |
|
63 | - $this->tokenProvider = $tokenProvider; |
|
64 | - $this->session = $session; |
|
65 | - $this->initialState = $initialState; |
|
66 | - $this->uid = $UserId; |
|
67 | - $this->userSession = $userSession; |
|
68 | - } |
|
69 | - |
|
70 | - public function getForm(): TemplateResponse { |
|
71 | - $this->initialState->provideInitialState( |
|
72 | - 'app_tokens', |
|
73 | - $this->getAppTokens() |
|
74 | - ); |
|
75 | - |
|
76 | - $this->initialState->provideInitialState( |
|
77 | - 'can_create_app_token', |
|
78 | - $this->userSession->getImpersonatingUserID() === null |
|
79 | - ); |
|
80 | - |
|
81 | - return new TemplateResponse('settings', 'settings/personal/security/authtokens'); |
|
82 | - } |
|
83 | - |
|
84 | - public function getSection(): string { |
|
85 | - return 'security'; |
|
86 | - } |
|
87 | - |
|
88 | - public function getPriority(): int { |
|
89 | - return 100; |
|
90 | - } |
|
91 | - |
|
92 | - private function getAppTokens(): array { |
|
93 | - $tokens = $this->tokenProvider->getTokenByUser($this->uid); |
|
94 | - |
|
95 | - try { |
|
96 | - $sessionId = $this->session->getId(); |
|
97 | - } catch (SessionNotAvailableException $ex) { |
|
98 | - return []; |
|
99 | - } |
|
100 | - try { |
|
101 | - $sessionToken = $this->tokenProvider->getToken($sessionId); |
|
102 | - } catch (InvalidTokenException $ex) { |
|
103 | - return []; |
|
104 | - } |
|
105 | - |
|
106 | - return array_map(function (IToken $token) use ($sessionToken) { |
|
107 | - $data = $token->jsonSerialize(); |
|
108 | - $data['canDelete'] = true; |
|
109 | - $data['canRename'] = $token instanceof INamedToken; |
|
110 | - if ($sessionToken->getId() === $token->getId()) { |
|
111 | - $data['canDelete'] = false; |
|
112 | - $data['canRename'] = false; |
|
113 | - $data['current'] = true; |
|
114 | - } |
|
115 | - return $data; |
|
116 | - }, $tokens); |
|
117 | - } |
|
43 | + /** @var IAuthTokenProvider */ |
|
44 | + private $tokenProvider; |
|
45 | + |
|
46 | + /** @var ISession */ |
|
47 | + private $session; |
|
48 | + |
|
49 | + /** @var IInitialState */ |
|
50 | + private $initialState; |
|
51 | + |
|
52 | + /** @var string|null */ |
|
53 | + private $uid; |
|
54 | + |
|
55 | + /** @var IUserSession */ |
|
56 | + private $userSession; |
|
57 | + |
|
58 | + public function __construct(IAuthTokenProvider $tokenProvider, |
|
59 | + ISession $session, |
|
60 | + IUserSession $userSession, |
|
61 | + IInitialState $initialState, |
|
62 | + ?string $UserId) { |
|
63 | + $this->tokenProvider = $tokenProvider; |
|
64 | + $this->session = $session; |
|
65 | + $this->initialState = $initialState; |
|
66 | + $this->uid = $UserId; |
|
67 | + $this->userSession = $userSession; |
|
68 | + } |
|
69 | + |
|
70 | + public function getForm(): TemplateResponse { |
|
71 | + $this->initialState->provideInitialState( |
|
72 | + 'app_tokens', |
|
73 | + $this->getAppTokens() |
|
74 | + ); |
|
75 | + |
|
76 | + $this->initialState->provideInitialState( |
|
77 | + 'can_create_app_token', |
|
78 | + $this->userSession->getImpersonatingUserID() === null |
|
79 | + ); |
|
80 | + |
|
81 | + return new TemplateResponse('settings', 'settings/personal/security/authtokens'); |
|
82 | + } |
|
83 | + |
|
84 | + public function getSection(): string { |
|
85 | + return 'security'; |
|
86 | + } |
|
87 | + |
|
88 | + public function getPriority(): int { |
|
89 | + return 100; |
|
90 | + } |
|
91 | + |
|
92 | + private function getAppTokens(): array { |
|
93 | + $tokens = $this->tokenProvider->getTokenByUser($this->uid); |
|
94 | + |
|
95 | + try { |
|
96 | + $sessionId = $this->session->getId(); |
|
97 | + } catch (SessionNotAvailableException $ex) { |
|
98 | + return []; |
|
99 | + } |
|
100 | + try { |
|
101 | + $sessionToken = $this->tokenProvider->getToken($sessionId); |
|
102 | + } catch (InvalidTokenException $ex) { |
|
103 | + return []; |
|
104 | + } |
|
105 | + |
|
106 | + return array_map(function (IToken $token) use ($sessionToken) { |
|
107 | + $data = $token->jsonSerialize(); |
|
108 | + $data['canDelete'] = true; |
|
109 | + $data['canRename'] = $token instanceof INamedToken; |
|
110 | + if ($sessionToken->getId() === $token->getId()) { |
|
111 | + $data['canDelete'] = false; |
|
112 | + $data['canRename'] = false; |
|
113 | + $data['current'] = true; |
|
114 | + } |
|
115 | + return $data; |
|
116 | + }, $tokens); |
|
117 | + } |
|
118 | 118 | } |