Finish remove user implementation
This commit is contained in:
parent
2783e385a4
commit
b0c78dde76
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.8.2, 2020-05-20T23:51:30. -->
|
<!-- Written by QtCreator 4.8.2, 2020-05-26T01:36:37. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
@ -42,6 +42,7 @@ void conexion_ssl::start_server(){
|
|||||||
while(1) {
|
while(1) {
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
uint len = sizeof(addr);
|
uint len = sizeof(addr);
|
||||||
|
|
||||||
int client = accept(sock, (struct sockaddr*)&addr, &len);
|
int client = accept(sock, (struct sockaddr*)&addr, &len);
|
||||||
std::thread t_client(conexion_client,ctx , client);
|
std::thread t_client(conexion_client,ctx , client);
|
||||||
t_client.detach();
|
t_client.detach();
|
||||||
|
@ -15,6 +15,7 @@ public:
|
|||||||
virtual void write_remove(std::string)=0;
|
virtual void write_remove(std::string)=0;
|
||||||
virtual bool get_package_exists(std::string package)=0;
|
virtual bool get_package_exists(std::string package)=0;
|
||||||
virtual void create_user(std::string user, std::string pass, bool admin)=0;
|
virtual void create_user(std::string user, std::string pass, bool admin)=0;
|
||||||
|
virtual void remove_user(std::string user)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATA_ACCES_H
|
#endif // DATA_ACCES_H
|
||||||
|
@ -97,3 +97,10 @@ void msql_acces::create_user(std::string user, std::string pass, bool admin){
|
|||||||
pstmt->setBoolean(3,admin);
|
pstmt->setBoolean(3,admin);
|
||||||
sql::ResultSet *res = pstmt->executeQuery();
|
sql::ResultSet *res = pstmt->executeQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void msql_acces::remove_user(std::string user){
|
||||||
|
sql::PreparedStatement *pstmt =
|
||||||
|
con->prepareStatement("delete from users where username=?");
|
||||||
|
pstmt->setString(1,user);
|
||||||
|
pstmt->executeUpdate();
|
||||||
|
}
|
||||||
|
@ -19,6 +19,7 @@ public:
|
|||||||
void write_remove(std::string);
|
void write_remove(std::string);
|
||||||
bool get_package_exists(std::string package);
|
bool get_package_exists(std::string package);
|
||||||
void create_user(std::string user, std::string pass, bool admin);
|
void create_user(std::string user, std::string pass, bool admin);
|
||||||
|
void remove_user(std::string user);
|
||||||
private:
|
private:
|
||||||
sql::Connection *con;
|
sql::Connection *con;
|
||||||
sql::Driver *driver;
|
sql::Driver *driver;
|
||||||
|
@ -42,6 +42,8 @@ void session_manager::start_dialog(){
|
|||||||
this->send_user_info();
|
this->send_user_info();
|
||||||
}else if(strcmp(buffer,"cusr")==0){
|
}else if(strcmp(buffer,"cusr")==0){
|
||||||
this->create_user();
|
this->create_user();
|
||||||
|
}else if(strcmp(buffer,"rusr")==0){
|
||||||
|
this->remove_user();
|
||||||
}else if((strcmp(buffer,"exit")==0)||(n_read==0)){
|
}else if((strcmp(buffer,"exit")==0)||(n_read==0)){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -135,6 +137,8 @@ void session_manager::create_user(){
|
|||||||
char* user=new char[256];
|
char* user=new char[256];
|
||||||
char* pass=new char[256];
|
char* pass=new char[256];
|
||||||
char* admin=new char[256];
|
char* admin=new char[256];
|
||||||
|
//basura
|
||||||
|
this->read_data(user, 256);
|
||||||
this->read_data(user, 256);
|
this->read_data(user, 256);
|
||||||
this->read_data(pass, 256);
|
this->read_data(pass, 256);
|
||||||
this->read_data(admin, 256);
|
this->read_data(admin, 256);
|
||||||
@ -144,6 +148,13 @@ void session_manager::create_user(){
|
|||||||
delete [] (admin);
|
delete [] (admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void session_manager::remove_user(){
|
||||||
|
char *buffer=new char[256];
|
||||||
|
this->read_data(buffer,256);
|
||||||
|
this->read_data(buffer,256);
|
||||||
|
this->data->remove_user(std::string(buffer));
|
||||||
|
}
|
||||||
|
|
||||||
int session_manager::read_data(char* input, int size){
|
int session_manager::read_data(char* input, int size){
|
||||||
return read(this->fd, input, size);
|
return read(this->fd, input, size);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ public:
|
|||||||
void send_user_info();
|
void send_user_info();
|
||||||
bool validate_pass();
|
bool validate_pass();
|
||||||
void create_user();
|
void create_user();
|
||||||
|
void remove_user();
|
||||||
private:
|
private:
|
||||||
std::string appli_command(char comand[], char* n_package);
|
std::string appli_command(char comand[], char* n_package);
|
||||||
virtual int read_data(char* input, int size);
|
virtual int read_data(char* input, int size);
|
||||||
|
Loading…
Reference in New Issue
Block a user