added CORS

This commit is contained in:
2026-02-16 23:24:31 +01:00
parent 14b8234e77
commit 58d37b51b7
27 changed files with 80 additions and 32 deletions

30
source/login/loginDb.hpp Normal file
View File

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