/** * Sets a redirect messages and redirects to the given internal path * * @param int|bool $success * @param string $text * @param string|null $path * * @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse */ public function setMessage($success, $text, $path = null) { $this->sessionHandler->set('redirect_message', ['success' => is_int($success) ? true : (bool) $success, 'text' => $text]); // If no path has been given, guess it automatically if ($path === null) { $path = $this->request->getModuleAndController(); } return $this->redirect->temporary($path); }
/** * Generates and renders the form token * * @return string */ public function renderFormToken() { $tokenName = Core\Session\SessionHandlerInterface::XSRF_TOKEN_NAME; $sessionToken = $this->sessionHandler->get($tokenName); if (empty($sessionToken)) { $sessionToken = sha1(uniqid(mt_rand(), true)); $this->sessionHandler->set($tokenName, $sessionToken); } return '<input type="hidden" name="' . $tokenName . '" value="' . $sessionToken . '" />'; }
/** * Erzeugt das Captchafeld für das Template * * @param integer $captchaLength * @param string $formFieldId * @param bool $inputOnly * @param string $path * * @return string */ public function captcha($captchaLength = self::CAPTCHA_DEFAULT_LENGTH, $formFieldId = self::CAPTCHA_DEFAULT_INPUT_ID, $inputOnly = false, $path = '') { if ($this->user->isAuthenticated() === false) { $path = sha1($this->router->route(empty($path) === true ? $this->request->getQuery() : $path)); $this->sessionHandler->set('captcha_' . $path, $this->secureHelper->salt($captchaLength)); $this->view->assign('captcha', ['width' => $captchaLength * 25, 'id' => $formFieldId, 'height' => 30, 'input_only' => $inputOnly, 'path' => $path]); return $this->view->fetchTemplate('Captcha/Partials/captcha.tpl'); } return ''; }
private function setSessionValues() { $this->sessionHandler->set(self::AUTH_NAME, ['id' => $this->userModel->getUserId(), 'super_user' => $this->userModel->isSuperUser(), 'language' => $this->userModel->getLanguage()]); }