/** * Gets the generated redirect message from setMessage() * * @return array|null * @throws \Exception */ public function getMessage() { $param = $this->sessionHandler->get('redirect_message'); if (isset($param) && is_array($param)) { $this->sessionHandler->remove('redirect_message'); } return $param; }
/** * @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; }
/** * @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, '')); }