Files
shadowrun-server/source/login/loginDb.hpp

31 lines
848 B
C++

#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__