app = $app; } /** * Find a matching user given a token * * @param Token $token * * @return null|\User_Adapter * * @throws NotAuthenticatedException In case the token is not authenticated. */ public function find(Token $token) { $infos = $token->getIdentity(); if ($infos->has(Identity::PROPERTY_EMAIL)) { $sql = 'SELECT usr_id FROM usr WHERE usr_mail = :email'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute(array(':email' => $infos->get(Identity::PROPERTY_EMAIL))); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); if ($row) { return \User_Adapter::getInstance($row['usr_id'], $this->app); } } return null; } }