From ad0fb5a10ee0d85504290efc5fb9d70199ffb40e Mon Sep 17 00:00:00 2001 From: Tina_Azure <-> Date: Thu, 27 Apr 2023 00:34:07 +0200 Subject: [PATCH] database request to delete all expired reset keys --- src/database.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/database.cpp b/src/database.cpp index 23f5fa6..83340e8 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -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