* @param $token * @param string $password * @return TemplateResponse|RedirectResponse */
($token, string $password = '')
| 207 | * @return TemplateResponse|RedirectResponse |
| 208 | */ |
| 209 | #[PublicPage] |
| 210 | #[UseSession] |
| 211 | #[NoCSRFRequired] |
| 212 | public function indexPublicMin($token, string $password = '') |
| 213 | { |
| 214 | $share = $this->ShareService->getReportByToken($token); |
| 215 | |
| 216 | if (empty($share)) { |
| 217 | // Dataset not shared or wrong token |
| 218 | return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', [ |
| 219 | 'redirect_url' => $this->urlGenerator->linkToRoute($this->appName . '.page.report', ['token' => $token]), |
| 220 | ])); |
| 221 | } else { |
| 222 | if ($share['password'] !== null) { |
| 223 | $password = $password !== '' ? $password : (string)$this->DataSession->getPasswordForShare($token); |
| 224 | $passwordVerification = $this->ShareService->verifyPassword($password, $share['password']); |
| 225 | if ($passwordVerification === true) { |
| 226 | $this->DataSession->setPasswordForShare($token, $password); |
| 227 | } else { |
| 228 | $this->DataSession->removePasswordForShare($token); |
| 229 | return new TemplateResponse($this->appName, 'authenticate', ['wrongpw' => $password !== '',], 'guest'); |
| 230 | } |
| 231 | } |
| 232 | $params = array(); |
| 233 | $params['data'] = $this->outputController->getData($share); |
| 234 | $params['baseurl'] = str_replace('/img/app.svg', '', $this->urlGenerator->imagePath('analytics', 'app.svg')); |
| 235 | $params['nonce'] = \OC::$server->getContentSecurityPolicyNonceManager()->getNonce(); |
| 236 | $response = new StandaloneTemplateResponse($this->appName, 'publicMin', $params, ''); |
| 237 | $csp = new ContentSecurityPolicy(); |
| 238 | $csp->addAllowedScriptDomain('*'); |
| 239 | $csp->addAllowedFrameAncestorDomain($share['domain']); |
| 240 | $response->setContentSecurityPolicy($csp); |
| 241 | return $response; |
| 242 | } |
| 243 | } |
| 244 | } |
nothing calls this directly
no test coverage detected