Database handler check if a given hash is valid
This commit is contained in:
@ -60,6 +60,13 @@ namespace Database {
|
||||
*/
|
||||
const static std::string PREPARED_STATEMENT_SELECT_FREELANCER_SALT = "selectFreelancerSalt";
|
||||
const static std::string SQL_STATEMENT_SELECT_FREELANCER_SALT = "select salt from freelancers where emailaddress = $1;";
|
||||
|
||||
/*
|
||||
* Name and Statement for prepared statement to check if hash is valid
|
||||
*/
|
||||
const static std::string PREPARED_STATEMENT_SELECT_CHECK_HASH_VALID = "selectCheckHashValid";
|
||||
const static std::string SQL_STATEMENT_SELECT_CHECK_HASH_VALID = "select count(*) from freelancers where emailaddress = $1 AND hash = $2;";
|
||||
|
||||
/*
|
||||
* Name and Statement for prepared statement to select a freelancer based on a given id
|
||||
*/
|
||||
@ -342,6 +349,20 @@ namespace Database {
|
||||
work.commit();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes the prepared statement SELECT_CHECK_HASH_VALID
|
||||
* Takes an open pqxx::connection and the emailAddress and hash to check
|
||||
* Delivers 0 if email + hash are not valid 1 if they are
|
||||
*/
|
||||
pqxx::result executePreparedStatement_SELECT_CHECK_HASH_VALID(pqxx::connection &connection, std::string emailAddress, std::string hash) {
|
||||
connection.prepare(PREPARED_STATEMENT_SELECT_CHECK_HASH_VALID, SQL_STATEMENT_SELECT_CHECK_HASH_VALID);
|
||||
pqxx::work work(connection);
|
||||
pqxx::result result = work.exec_prepared(PREPARED_STATEMENT_SELECT_CHECK_HASH_VALID, emailAddress, hash);
|
||||
work.commit();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes the prepared statement SELECT_TEMPLATE
|
||||
* Takes an open pqxx::connection and the id to select by
|
||||
|
Reference in New Issue
Block a user