Update DBLogin.cpp
This commit is contained in:
@@ -11,19 +11,19 @@ return 1 if admin | 0 if not admin | -1 if failed
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int DBLogin::checkValidLogin(int id, std::string pw) {
|
int DBLogin::checkValidLogin(std::string id, std::string pw) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pqxx::work worker(connectionObject);
|
pqxx::work worker(connectionObject);
|
||||||
|
|
||||||
std::string query =
|
std::string query =
|
||||||
"SELECT admin FROM studenten_veranstalterr WHERE id = $1 AND passwort = $2";
|
"SELECT admin FROM studenten_veranstalter WHERE id = $1 AND passwort = $2";
|
||||||
|
|
||||||
pqxx::result response = worker.exec_params(query, id, pw);
|
pqxx::result response = worker.exec_params(query, id, pw);
|
||||||
|
|
||||||
if (response.affected_rows() > 0) {
|
if (response.affected_rows() > 0) {
|
||||||
|
|
||||||
std::cout << response[0][0] << std::endl;
|
|
||||||
if (response[0][0].is_null())
|
if (response[0][0].is_null())
|
||||||
return 0;
|
return 0;
|
||||||
return response[0][0].as<bool>();
|
return response[0][0].as<bool>();
|
||||||
@@ -31,10 +31,11 @@ int DBLogin::checkValidLogin(int id, std::string pw) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user