/** * Load connection parameters from config file. * * @access private * @param string $connection Connection group name */ private function setBuilder($width = 150, $height = 40, $font = null) { if ($this->session->has($this->secret . '::phrase') && $this->isAlive()) { // Get phrase saved in session $sessionPhrase = $this->session->get($this->secret . '::phrase'); // Decrypt phrase $phrase = $this->encrypter->decrypt($sessionPhrase); // Captcha builder $this->builder = new CaptchaBuilder($phrase); $this->builder->setDistortion(false); $this->builder->setMaxBehindLines(0); $this->builder->setMaxFrontLines(0); $this->builder->setIgnoreAllEffects(false); $this->builder->setBackgroundColor(241, 241, 241); $this->builder->build($width, $height, $font); } else { // Captcha builder $this->builder = new CaptchaBuilder(); $this->builder->setDistortion(false); $this->builder->setMaxBehindLines(0); $this->builder->setMaxFrontLines(0); $this->builder->setIgnoreAllEffects(false); $this->builder->setBackgroundColor(241, 241, 241); $this->builder->build($width, $height, $font); // Set last generated phrase $this->session->put($this->secret . '::phrase', $this->encrypter->encrypt($this->builder->getPhrase())); // Set last modified time $this->session->put($this->secret . '::lastModified', time()); } }
/** * Logs in a user with a valid email/password combination. * Returns TRUE if the email + password combination matches and the user is activated and not banned. * A status code (LOGIN_ACTIVATING, LOGIN_BANNED or LOGIN_INCORRECT) will be retured in all other situations. * * @access public * @param string $email User email * @param string $password User password * @param boolean $remember (optional) Set a remember me cookie? * @param boolean $force (optional) Login the user without checking the password? * @param boolean $callback (optional) Set additional query parameters * @return boolean|int */ public function login($email, $password, $remember = false, $force = false, $callback = false) { $authenticated = $this->authenticate($email, $password, $force, $callback); if ($authenticated === true) { $this->session->regenerateId(); $this->session->put($this->authKey, $this->user->getToken()); if ($remember === true) { $this->response->signedCookie($this->authKey, $this->user->getToken(), 3600 * 24 * 365, $this->cookieOptions); } return true; } return $authenticated; }
/** * Logs in a user with a valid email/password combination. * Returns TRUE if the email + password combination matches and the user is activated and not banned. * A status code (LOGIN_ACTIVATING, LOGIN_BANNED or LOGIN_INCORRECT, LOGIN_LOCKED) will be retured in all other situations. * * @access public * @param string $identifier User email * @param string $password User password * @param boolean $remember Set a remember me cookie? * @param boolean $force Login the user without checking the password? * @return boolean|int */ public function login($identifier, $password, $remember = false, $force = false) { if (empty($identifier)) { return static::LOGIN_INCORRECT; } $authenticated = $this->authenticate($identifier, $password, $force); if ($authenticated === true) { $this->session->regenerateId(); $this->session->regenerateToken(); $this->session->put($this->authKey, $this->user->getAccessToken()); if ($remember === true) { $this->response->signedCookie($this->authKey, $this->user->getAccessToken(), 3600 * 24 * 365, $this->cookieOptions); } return true; } return $authenticated; }