diff --git a/src/Controller/ViewerController.php b/src/Controller/ViewerController.php index 7966d9f7..06ff90d4 100644 --- a/src/Controller/ViewerController.php +++ b/src/Controller/ViewerController.php @@ -129,18 +129,18 @@ protected function getViewerRender(Media $media, string $wopi_client, bool $can_ $id = $media->id(); - $ttl = $this->coolJwt->getAccessTokenTtl(); - if ($ttl == 0) { - $ttl = 86400; + $ttl_seconds = $this->coolJwt->getTtlSeconds(); + if ($ttl_seconds == 0) { + $ttl_seconds = 86400; } - $access_token = $this->coolJwt->tokenForFileId($id, $ttl, $can_write); + $access_token = $this->coolJwt->tokenForFileId($id, $ttl_seconds, $can_write); $render_array = [ '#wopiClient' => $wopi_client, '#wopiSrc' => urlencode($wopi_base . '/cool/wopi/files/' . $id), '#accessToken' => $access_token, - // It's in usec. The JWT is in sec. - '#accessTokenTtl' => $ttl * 1000, + // Convert to milliseconds. + '#accessTokenTtl' => $ttl_seconds * 1000, '#allowfullscreen' => $allowfullscreen ? 'allowfullscreen' : '', ]; if ($options) { diff --git a/src/Service/CoolJwt.php b/src/Service/CoolJwt.php index 83031917..277a412f 100644 --- a/src/Service/CoolJwt.php +++ b/src/Service/CoolJwt.php @@ -130,7 +130,7 @@ public function tokenForFileId($id, $ttl, $can_write = FALSE) { * @return int * Token TTL in seconds. */ - public function getAccessTokenTtl() { + public function getTtlSeconds() { $default_config = $this->configFactory->get('collabora_online.settings'); $ttl = $default_config->get('cool')['access_token_ttl'];