database request to delete all expired reset keys

This commit is contained in:
Tina_Azure
2023-04-27 00:34:07 +02:00
parent 9483baa68c
commit ad0fb5a10e

View File

@ -118,6 +118,12 @@ namespace Database {
const static std::string PREPARED_STATEMENT_UPDATE_FREELANCER_PASSWORD_HASH = "updateFreelancerPasswordHash";
const static std::string SQL_STATEMENT_UPDATE_FREELANCER_PASSWORD_HASH = "update freelancers set hash = $1, salt = $2 where emailaddress = $3;";
/*
* Statement to remove expired reset keys
*/
const static std::string SQL_STATEMENT_PURGE_EXPIRED_FREELANCER_RESET_KEYS = "delete from passwordresetkeys where expiration <= CURRENT_TIMESTAMP;";
/*
* Selects freelancers, their basicInfo and if the commissions are closed/open ordered by name.
* Delivers if the commission limit has been reached and if the commissions are closed based on the accepted/completed state of the freelancers requests
@ -301,6 +307,17 @@ namespace Database {
return result;
}
/*
* Executes the PURGE_EXPIRED_FREELANCER_RESET_KEYS statement
* Takes an open pqxx::connection
* todo::regular execution
*/
void executeStatement_STATEMENT_PURGE_EXPIRED_FREELANCER_RESET_KEYS(pqxx::connection &connection) {
pqxx::work work(connection);
work.exec(SQL_STATEMENT_PURGE_EXPIRED_FREELANCER_RESET_KEYS);
work.commit();
}
/*
* Executes the prepared statement SELECT_ITEM_BY_ID
* Takes an open pqxx::connection and the id to select by