creating json for new user

This commit is contained in:
Benedikt Galbavy 2023-10-16 13:16:47 +02:00
parent ddb1c277a3
commit 99e34a1faa
3 changed files with 21 additions and 5 deletions

View File

@ -1,8 +1,24 @@
#include "user.h" #include "user.h"
user::user(fs::path) #include <fstream>
#include <string>
using json = nlohmann::json;
user::user(fs::path user_data)
{ {
// json stuff go here // json stuff go here
} }
user::user(std::string name, fs::path user_dir)
: name(name)
{
json user;
user["mails"] = json::array();
user["name"] = name;
std::ofstream ofs(user_dir/(name+".json"));
ofs << user;
}
user::~user() {} user::~user() {}

5
user.h
View File

@ -17,9 +17,8 @@ typedef std::set<mail*, decltype(ptr_cmp<int>)> maillist;
class user { class user {
public: public:
user(fs::path); user(fs::path user_data);
user(std::string name) user(std::string name, fs::path user_dir);
: name(name) {};
~user(); ~user();

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "user.h" #include "user.h"
#include <filesystem> #include <filesystem>
#include <map> #include <map>
#include <string> #include <string>