MCPcopy Create free account
hub / github.com/Rello/analytics / indexPublicMin

Method indexPublicMin

lib/Controller/PageController.php:209–243  ·  view source on GitHub ↗

* @param $token * @param string $password * @return TemplateResponse|RedirectResponse */

($token, string $password = '')

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 7

getPasswordForShareMethod · 0.80
verifyPasswordMethod · 0.80
setPasswordForShareMethod · 0.80
getReportByTokenMethod · 0.45
getDataMethod · 0.45
imagePathMethod · 0.45

Tested by

no test coverage detected