add normal user restrictions
This commit is contained in:
parent
b0c78dde76
commit
df772fec57
@ -9,6 +9,7 @@ class data_acces
|
|||||||
public:
|
public:
|
||||||
data_acces();
|
data_acces();
|
||||||
virtual std::string get_passwd(std::string username) = 0;
|
virtual std::string get_passwd(std::string username) = 0;
|
||||||
|
virtual bool get_admin(std::string)=0;
|
||||||
virtual std::list<std::string> get_pinfo()=0;
|
virtual std::list<std::string> get_pinfo()=0;
|
||||||
virtual std::list<std::string> get_uinfo()=0;
|
virtual std::list<std::string> get_uinfo()=0;
|
||||||
virtual void write_install(std::string package, std::string user)=0;
|
virtual void write_install(std::string package, std::string user)=0;
|
||||||
|
@ -19,6 +19,17 @@ std::string msql_acces::get_passwd(std::string username){
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool msql_acces::get_admin(std::string username){
|
||||||
|
sql::PreparedStatement *pstmt = con->prepareStatement("select admin from users where username=?");
|
||||||
|
pstmt->setString(1,username);
|
||||||
|
sql::ResultSet *res = pstmt->executeQuery();
|
||||||
|
bool ret=false;
|
||||||
|
while(res->next())
|
||||||
|
ret = res->getBoolean("admin");
|
||||||
|
delete res;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
std::list<std::string> msql_acces::get_pinfo(){
|
std::list<std::string> msql_acces::get_pinfo(){
|
||||||
sql::PreparedStatement *pstmt =
|
sql::PreparedStatement *pstmt =
|
||||||
con->prepareStatement("select packages.name, packages.created, packages.uses, users.username "
|
con->prepareStatement("select packages.name, packages.created, packages.uses, users.username "
|
||||||
|
@ -13,6 +13,7 @@ class msql_acces : public data_acces
|
|||||||
public:
|
public:
|
||||||
msql_acces();
|
msql_acces();
|
||||||
std::string get_passwd(std::string username);
|
std::string get_passwd(std::string username);
|
||||||
|
bool get_admin(std::string);
|
||||||
std::list<std::string> get_pinfo();
|
std::list<std::string> get_pinfo();
|
||||||
std::list<std::string> get_uinfo();
|
std::list<std::string> get_uinfo();
|
||||||
void write_install(std::string package, std::string user);
|
void write_install(std::string package, std::string user);
|
||||||
|
@ -20,6 +20,11 @@ bool session_manager::validate_pass(){
|
|||||||
std::string pass=buffer;
|
std::string pass=buffer;
|
||||||
if(this->data->get_passwd(user)==pass){
|
if(this->data->get_passwd(user)==pass){
|
||||||
this->write_data("pass");
|
this->write_data("pass");
|
||||||
|
if(this->data->get_admin(user)){
|
||||||
|
this->write_data("admin");
|
||||||
|
}else{
|
||||||
|
this->write_data("norma");
|
||||||
|
}
|
||||||
this->user=user;
|
this->user=user;
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
Reference in New Issue
Block a user