Update folders

This commit is contained in:
AJ
2024-07-06 12:03:41 +02:00
parent b683d39a68
commit 5885f01dc0
22 changed files with 4394 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
#include "DBLogin.hpp"
#include <iostream>
DBLogin::DBLogin(std::string connStr) : DBHandler(connStr) {};
/*
return 1 if admin | 0 if not admin | -1 if failed
*/
int DBLogin::checkValidLogin(std::string id, std::string pw) {
try {
pqxx::work worker(connectionObject);
std::string query =
"SELECT admin FROM studenten_veranstalter WHERE id = $1 AND passwort = $2";
pqxx::result response = worker.exec_params(query, id, pw);
if (response.affected_rows() > 0) {
if (response[0][0].is_null())
return 0;
return response[0][0].as<bool>();
}
return -1;
}
catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
}