public function testDeleteAuthTokenOnLogout() { //insert a new user $sql = "Delete from `usuario` where `codigo_usuario` = 'foo';"; global $POS_CONFIG; $POS_CONFIG["INSTANCE_CONN"]->Execute($sql); $r = PersonalYagentesController::NuevoUsuario("foo", "1", "name", "password444222"); $r = SesionController::Iniciar("password444222", "foo"); //this token should be non existing when i log out $auth_token = $r["auth_token"]; $vos = SesionDAO::search(new Sesion(array("auth_token" => $auth_token))); $r = SesionController::Cerrar($auth_token); $vos = SesionDAO::search(new Sesion(array("auth_token" => $auth_token))); $this->assertEquals(sizeof($vos), 0); }
public static function getCurrentUser() { if (!is_null(self::$_current_user)) { return self::$_current_user; } $auth_token = null; if (isset($_GET["auth_token"])) { $auth_token = $_GET["auth_token"]; } else { if (isset($_POST["auth_token"])) { $auth_token = $_POST["auth_token"]; } else { if (isset($_GET["at"])) { $auth_token = $_GET["at"]; } else { if (isset($_POST["at"])) { $auth_token = $_POST["at"]; } else { $sm = SessionManager::getInstance(); $auth_token = $sm->GetCookie("at"); } } } } self::$_current_user = null; if (!is_null($auth_token)) { self::$_current_user = SesionDAO::getUserByAuthToken($auth_token); } /* //there is authtoken in the POST message if( isset($_POST["at"]) && !is_null($_POST["at"]) ){ //Logger::log("post"); self::$_current_user = SesionDAO::getUserByAuthToken( $_POST["at"] ); } //there is authtoken in the GET message if(isset($_GET["at"]) && !is_null($_GET["at"])){ //Logger::log("get"); self::$_current_user = SesionDAO::getUserByAuthToken( $_GET["at"] ); } */ return self::$_current_user; }