Skip to content

Commit

Permalink
Use PublicTemplateResponse
Browse files Browse the repository at this point in the history
attempt to fix #141
  • Loading branch information
githubkoma authored Mar 21, 2021
1 parent 3fb8d0a commit a79afbd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drawio/controller/viewercontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace OCA\Drawio\Controller;

use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
use OCP\AppFramework\Http\DataDownloadResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\ContentSecurityPolicy;
Expand Down Expand Up @@ -49,6 +50,7 @@ class ViewerController extends Controller
private $trans;
private $logger;
private $config;
private $userId;
/**
* Session
*
Expand Down Expand Up @@ -82,7 +84,8 @@ public function __construct($AppName,
ILogger $logger,
AppConfig $config,
IManager $shareManager,
ISession $session
ISession $session,
$UserId
)
{
parent::__construct($AppName, $request);
Expand All @@ -95,6 +98,7 @@ public function __construct($AppName,
$this->config = $config;
$this->shareManager = $shareManager;
$this->session = $session;
$this->userId = $UserId;
}


Expand Down Expand Up @@ -200,7 +204,11 @@ public function index($fileId, $shareToken = NULL, $filePath = NULL) {

}

$response = new TemplateResponse($this->appName, "viewer", $params);
if ($this->userId) {
$response = new TemplateResponse($this->appName, "viewer", $params);
} else {
$response = new PublicTemplateResponse($this->appName, "viewer", $params);
}

$csp = new ContentSecurityPolicy();
$csp->allowInlineScript(true);
Expand Down

0 comments on commit a79afbd

Please sign in to comment.