/** * Get generated phrase * * @access private * @return string */ private function isAlive() { // Get how many times the captcha stil valid $timeToLive = $this->config->get('makocaptcha::config.ttl'); // Validate time $lastModified = $this->session->get($this->secret . '::lastModified', null); if (is_null($lastModified) || $lastModified < time() - $timeToLive) { return false; } return true; }
/** * Checks if a user is logged in. * * @access protected * @return mako\auth\user\UserInterface|null */ protected function check() { if (empty($this->user)) { // Check if there'a user that can be logged in $token = $this->session->get($this->authKey, false); if ($token === false) { $token = $this->request->signedCookie($this->authKey, false); if ($token !== false) { $this->session->put($this->authKey, $token); } } if ($token !== false) { $user = $this->userProvider->getByAccessToken($token); if ($user === false || $user->isBanned() || !$user->isActivated()) { $this->logout(); } else { $this->user = $user; } } } return $this->user; }
/** * Checks if a user is logged in. * * @access protected * @return \padlock\models\User|null */ protected function check() { if (empty($this->user)) { // Check if there'a user that can be logged in $token = $this->session->get($this->authKey, false); if ($token === false) { $token = $this->request->signedCookie($this->authKey, false); if ($token !== false) { $this->session->put($this->authKey, $token); } } if ($token !== false) { $model = $this->userModel; $this->user = $model::where('token', '=', $token)->first(); if ($this->user === false || $this->user->isBanned() || !$this->user->isActivated()) { $this->logout(); } } // Set checked status to TRUE $this->isChecked = true; } return $this->user; }