RePod-Nextcloud-App/lib/Controller/PageController.php

44 lines
971 B
PHP
Raw Normal View History

2023-06-24 17:18:27 +02:00
<?php
declare(strict_types=1);
namespace OCA\RePod\Controller;
use OCA\RePod\AppInfo\Application;
use OCP\AppFramework\Controller;
2023-07-03 00:12:40 +02:00
use OCP\AppFramework\Http\ContentSecurityPolicy;
2023-06-24 17:18:27 +02:00
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
2023-06-24 17:18:27 +02:00
use OCP\Util;
class PageController extends Controller
{
public function __construct(
private IConfig $config
) {}
2023-06-24 17:18:27 +02:00
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
2023-12-23 17:25:20 +01:00
public function index(): TemplateResponse {
Util::addScript(Application::APP_ID, 'main');
2023-06-24 17:18:27 +02:00
2023-07-03 00:12:40 +02:00
$csp = new ContentSecurityPolicy();
$csp->addAllowedImageDomain('*');
2023-08-27 12:45:19 +02:00
$csp->addAllowedMediaDomain('*');
2023-07-03 00:12:40 +02:00
if ($this->config->getSystemValueBool('debug', false)) {
/** @psalm-suppress DeprecatedInterface */
$csp->allowEvalScript();
$csp->addAllowedConnectDomain('*');
$csp->addAllowedScriptDomain('*');
}
$response = new TemplateResponse(Application::APP_ID, 'main');
2023-07-03 00:12:40 +02:00
$response->setContentSecurityPolicy($csp);
2023-07-27 23:01:24 +02:00
2023-07-03 00:12:40 +02:00
return $response;
2023-06-24 17:18:27 +02:00
}
}