2026-01-22 23:09:34 +01:00

34 lines
842 B
C++

#ifndef __LOGINDB_H__
#define __LOGINDB_H__
#include <cstdint>
#include <string>
#include <vector>
#include <optional>
#include "json.hpp"
#include "utils.hpp"
#include "sqlite_orm.h"
#include "magic_enum.hpp"
namespace login
{
struct User {
int id;
std::string username;
std::string password_hash;
std::string last_login;
std::string created_at; // SQLite stores DATETIME as TEXT
};
inline User newUser(const std::string& username, std::string password_hash){
return User {-1, username, password_hash, utils::currentTime(), utils::currentTime()};
}
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(User, id, username, password_hash, last_login, created_at)
int createUser(const std::string& username, const std::string& password_hash);
std::optional<User> getUser(const std::string& username);
}
#endif // __LOGINDB_H__