From 44bfd7e6064e613ca8803512e4ccc45e581b78fc Mon Sep 17 00:00:00 2001 From: groche97 Date: Tue, 2 Jun 2020 15:21:59 +0200 Subject: [PATCH] ad suport env variable --- ClienteTFG.pro.user | 2 +- conexion.cpp | 3 +++ conexion.h | 6 ++++++ session_manager.cpp | 8 ++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ClienteTFG.pro.user b/ClienteTFG.pro.user index 87220ea..631aea8 100644 --- a/ClienteTFG.pro.user +++ b/ClienteTFG.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/conexion.cpp b/conexion.cpp index b09a9a3..a2c741f 100644 --- a/conexion.cpp +++ b/conexion.cpp @@ -46,3 +46,6 @@ ssize_t conexion::write_string(std::string entrada){ return write(this->fd,entrada.data(),entrada.size()); } +config_reader* conexion::get_conf(){ + return this->config; +} diff --git a/conexion.h b/conexion.h index 9062606..dbf70c3 100644 --- a/conexion.h +++ b/conexion.h @@ -26,6 +26,12 @@ public: * @return bytes sended */ virtual ssize_t write_string(std::string output); + /** + * @brief get_conf + * Get the config object + * @return Config object + */ + config_reader* get_conf(); protected: config_reader *config; int fd; diff --git a/session_manager.cpp b/session_manager.cpp index 28a8e19..5802dc7 100644 --- a/session_manager.cpp +++ b/session_manager.cpp @@ -6,6 +6,8 @@ session_manager::session_manager(conexion* con) this->con=con; } + + bool session_manager::loggin(std::string username, std::string passwd){ this->con->write_string(username); this->con->write_string(passwd); @@ -17,6 +19,12 @@ bool session_manager::loggin(std::string username, std::string passwd){ bool session_manager::admin(){ std::string result; this->con->read_string(result,5); + std::string env; + if(this->con->get_conf()->get_param("env", env)){ + this->con->write_string(env); + }else{ + this->con->write_string("no"); + } return result=="admin"; }