added better login support

This commit is contained in:
2025-10-22 21:37:28 +02:00
parent 5a1297dc80
commit 89e3b95ca2
4 changed files with 25 additions and 12 deletions

View File

@@ -8,6 +8,7 @@
#include <optional>
#include <set>
#include <map>
#include "crow.h"
class Database {
@@ -28,7 +29,7 @@ public:
template <typename T>
std::optional<T> getSqlData(sqlite3_stmt* stmt, int i)
{
if ((stmt == nullptr) || (sqlite3_step(stmt) != SQLITE_ROW))
if (stmt == nullptr)
return {};
if constexpr (std::is_same_v<T, int>) {
@@ -51,9 +52,10 @@ public:
template <typename T1, typename T2>
std::optional<std::pair<T1, T2>> get(const std::string sql, const QueryData& data){
sqlite3_stmt* stmt = bind(sql, data);
if ((stmt == nullptr) || (sqlite3_step(stmt) != SQLITE_ROW))
if ( (stmt == nullptr) || (sqlite3_step(stmt) != SQLITE_ROW ) ) {
CROW_LOG_ERROR << "Failed to run statement: " << sqlite3_errmsg(m_db);
return {};
}
std::optional<T1> v1 = getSqlData<T1>(stmt, 0);
std::optional<T2> v2 = getSqlData<T2>(stmt, 1);