add normal user restrictions
This commit is contained in:
parent
b0c78dde76
commit
df772fec57
@ -9,6 +9,7 @@ class data_acces
|
||||
public:
|
||||
data_acces();
|
||||
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_uinfo()=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;
|
||||
}
|
||||
|
||||
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(){
|
||||
sql::PreparedStatement *pstmt =
|
||||
con->prepareStatement("select packages.name, packages.created, packages.uses, users.username "
|
||||
|
@ -13,6 +13,7 @@ class msql_acces : public data_acces
|
||||
public:
|
||||
msql_acces();
|
||||
std::string get_passwd(std::string username);
|
||||
bool get_admin(std::string);
|
||||
std::list<std::string> get_pinfo();
|
||||
std::list<std::string> get_uinfo();
|
||||
void write_install(std::string package, std::string user);
|
||||
|
@ -20,6 +20,11 @@ bool session_manager::validate_pass(){
|
||||
std::string pass=buffer;
|
||||
if(this->data->get_passwd(user)==pass){
|
||||
this->write_data("pass");
|
||||
if(this->data->get_admin(user)){
|
||||
this->write_data("admin");
|
||||
}else{
|
||||
this->write_data("norma");
|
||||
}
|
||||
this->user=user;
|
||||
return true;
|
||||
}else{
|
||||
|
Loading…
Reference in New Issue
Block a user