/** * Check whether a user is valid (is authenticated)? * * @return bool */ public function isValid() { if ($this->userInstance !== null && $this->userInstance->offsetGet('activated') == 2) { return true; } return false; }
/** * Write identification Cookie * * @param AbstractUser $user * @param bool $remember */ private function writeCookie(AbstractUser $user, $remember) { if ($remember) { $cookie = new SetCookie($this->facade->domain, $user->offsetGet('id') . '::' . $user->offsetGet('token', true), time() + 3600 * 24 * 31, '/'); $this->response->getHeaders()->addHeader($cookie); $this->response->send(); } }
/** * Update attributes * * @param AbstractUser $user */ protected function updateAttributes(AbstractUser $user) { $user->offsetSet('ip', $this->network->getClientIp()); $user->offsetSet('userAgent', $this->network->getUserAgent()); if ($user->offsetGet('lastVisit') < time() - 90) { $user->offsetSet('lastVisit', time()); } }
/** * Update attributes * * @param AbstractUser $user */ public static function updateAttributes(AbstractUser $user, Request $request) { $user->offsetSet('ip', $request->getClientIp()); $user->offsetSet('user_agent', $request->getUserAgent()); if ($user->offsetGet('last_visit') < time() - 90) { $user->offsetSet('last_visit', time()); } }
/** * Write identification Cookie * * @param AbstractUser $user * @param bool $remember */ private function writeCookie(AbstractUser $user, $remember) { if ($remember) { $this->response->headers->setCookie(new Cookie($this->facade->domain, $user->offsetGet('id') . '::' . $user->offsetGet('token', true), time() + 3600 * 24 * 31)); $this->response->send(); } }