Skip to content

Commit

Permalink
Merge pull request #2260 from LibreSign/bugfixes/app-files
Browse files Browse the repository at this point in the history
Bugfixes app files
  • Loading branch information
vitormattos authored Feb 2, 2024
2 parents e28456b + 1b63cdc commit 3ba3197
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCA\Libresign\Listener\LoadSidebarListener;
use OCA\Libresign\Listener\NotificationListener;
use OCA\Libresign\Listener\SignedListener;
use OCA\Libresign\Middleware\GlobalInjectionMiddleware;
use OCA\Libresign\Middleware\InjectionMiddleware;
use OCA\Libresign\Notification\Notifier;
use OCP\AppFramework\App;
Expand Down Expand Up @@ -61,6 +62,7 @@ public function boot(IBootContext $context): void {
}

public function register(IRegistrationContext $context): void {
$context->registerMiddleWare(GlobalInjectionMiddleware::class, true);
$context->registerMiddleWare(InjectionMiddleware::class);

$context->registerNotifierService(Notifier::class);
Expand Down
42 changes: 42 additions & 0 deletions lib/Middleware/GlobalInjectionMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2024 Vitor Mattos <[email protected]>
*
* @author Vitor Mattos <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace OCA\Libresign\Middleware;

use OCA\Files\Controller\ViewController;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware;

class GlobalInjectionMiddleware extends Middleware {
public function afterController(Controller $controller, string $methodName, Response $response) {
if ($controller instanceof ViewController) {
$policy = new ContentSecurityPolicy();
$policy->allowEvalScript(true);
$response->setContentSecurityPolicy($policy);
}
return $response;
}
}
4 changes: 1 addition & 3 deletions src/Components/File/AppFilesTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default {
return {
file: {},
signers: [],
name: '',
requestedBy: {},
requestDate: '',
}
Expand All @@ -49,14 +48,13 @@ export default {
this.signers = []
this.file = {
nodeId: fileInfo.id,
name: fileInfo.name
}
this.name = fileInfo.name
this.requestedBy = {}
this.requestDate = ''
try {
const response = await axios.get(generateOcsUrl(`/apps/libresign/api/v1/file/validate/file_id/${fileInfo.id}`))
this.signers = response.data.signers
this.name = response.data.name
this.file.uuid = response.data.uuid
this.requestedBy = response.data.requested_by
this.requestDate = response.data.request_date
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Request/RequestSignature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default {
},
async save() {
const params = {
name: this.name,
name: this.name.length > 0 ? this.name : this.file?.name,
users: [],
}
this.dataSigners.forEach(signer => {
Expand Down
5 changes: 5 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<code>LoadSidebar</code>
</UndefinedClass>
</file>
<file src="lib/Middleware/GlobalInjectionMiddleware.php">
<UndefinedClass occurrences="1">
<code>ViewController</code>
</UndefinedClass>
</file>
<file src="lib/Migration/Version2040Date20211027183759.php">
<MissingDependency occurrences="3">
<code>$this-&gt;root</code>
Expand Down

0 comments on commit 3ba3197

Please sign in to comment.