/** * 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); }
/** * 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 ''; }
/** * @inheritdoc */ public function authenticate() { $userData = 0; if ($this->sessionHandler->has(AuthenticationModel::AUTH_NAME)) { $userData = $this->sessionHandler->get(AuthenticationModel::AUTH_NAME, []); } elseif ($this->request->getCookies()->has(AuthenticationModel::AUTH_NAME)) { list($userId, $token) = explode('|', $this->request->getCookies()->get(AuthenticationModel::AUTH_NAME, '')); $userData = $this->verifyCredentials($userId, $token); } $this->authenticationModel->authenticate($userData); }
/** * @param string $path * * @return \Symfony\Component\HttpFoundation\Response */ public function execute($path) { $this->response->headers->set('Content-type', 'image/gif'); $this->response->headers->addCacheControlDirective('no-cache', true); $this->response->headers->addCacheControlDirective('must-revalidate', true); $this->response->headers->add(['Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT']); if ($this->sessionHandler->has('captcha_' . $path)) { $this->generateCaptcha($this->sessionHandler->get('captcha_' . $path)); } return $this->response; }
/** * Removes the form token from the session * * @param string $token */ public function unsetFormToken($token = '') { $tokenName = Core\Session\SessionHandlerInterface::XSRF_TOKEN_NAME; if (empty($token) && $this->request->getPost()->has($tokenName)) { $token = $this->request->getPost()->get($tokenName, ''); } if (!empty($token)) { $sessionToken = $this->sessionHandler->get($tokenName); if (!empty($sessionToken)) { $this->sessionHandler->remove($tokenName); } } }
/** * @inheritdoc */ public function isValid($data, $field = '', array $extra = []) { $tokenName = SessionHandlerInterface::XSRF_TOKEN_NAME; $sessionToken = $this->sessionHandler->get($tokenName, ''); return $this->request->getPost()->get($tokenName, '') === $sessionToken; }
private function setSessionValues() { $this->sessionHandler->set(self::AUTH_NAME, ['id' => $this->userModel->getUserId(), 'super_user' => $this->userModel->isSuperUser(), 'language' => $this->userModel->getLanguage()]); }
/** * @param string $value * @param string $path * @return bool */ protected function checkCaptcha($value, $path) { $indexName = 'captcha_' . sha1($this->router->route(empty($path) === true ? $this->request->getQuery() : $path)); return preg_match('/^[a-zA-Z0-9]+$/', $value) && strtolower($value) === strtolower($this->sessionHandler->get($indexName, '')); }