login now works and files are protected

This commit is contained in:
2026-02-02 22:06:37 +01:00
parent 79b5737bcb
commit fbb54b461e
9 changed files with 149 additions and 105 deletions

View File

@@ -1,8 +1,11 @@
#include "loginDb.hpp"
#include "databasepool.h"
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <iostream>
extern "C" {
#include "monocypher.h"
}
@@ -59,8 +62,14 @@ int createUser(const std::string& username, const std::string& password){
int64_t id;
auto db = dbpool.acquire();
auto user = db->get_optional<User>(
where(c(&User::username) == username)
for (auto &u : db->get_all<login::User>()) {
if (u.username == username){
std::cout << "WTF" << std::endl;
};
}
auto user = db->get_optional<login::User>(
where(c(&login::User::username) == username)
);
if (user.has_value()) {
@@ -76,11 +85,16 @@ int createUser(const std::string& username, const std::string& password){
std::optional<User> getUser(const std::string& username){
auto db = dbpool.acquire();
auto user = db->get_optional<User>(
where(c(&User::username) == username)
auto user = db->get_all<login::User>(
where(c(&login::User::username) == username)
);
dbpool.release(db);
return user;
if(user.size() > 0){
return user[0];
}
return {};
}
std::optional<User> getVerifiedUser(const std::string& username, const std::string& password){
@@ -88,7 +102,7 @@ std::optional<User> getVerifiedUser(const std::string& username, const std::stri
if (!user.has_value())
return {};
if (verifyUser(user.value(), password)){
if (verifyUser(*user, password)){
return user;
}
return {};