app= $app; $this->persistent_cookie = $persistent_cookie; $browser = Browser::getInstance(); $conn = $this->app['phraseanet.appbox']->get_connection(); $sql = 'SELECT usr_id, session_id, nonce, token FROM cache WHERE token = :token'; $stmt = $conn->prepare($sql); $stmt->execute(array(':token' => $this->persistent_cookie)); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); if ( ! $row || count($row) == 0) { throw new Exception_Session_WrongToken(); } $string = $browser->getBrowser() . '_' . $browser->getPlatform(); if (User_Adapter::salt_password($this->app, $string, $row['nonce']) !== $row['token']) { throw new Exception_Session_WrongToken(); } $this->user = User_Adapter::getInstance($row['usr_id'], $this->app); $this->ses_id = (int) $row['session_id']; return $this; } public function prelog() { return $this; } /** * * @return User_Adapter */ public function get_user() { return $this->user; } /** * * @return int */ public function getSessionId() { return $this->ses_id; } /** * * @return User_Adapter */ public function signOn() { return $this->user; } /** * * @return Session_Authentication_PersistentCookie */ public function postlog() { return $this; } }