AdminDel/Del now delete logs aswell

This commit is contained in:
EntireTwix 2021-04-21 19:17:00 -07:00
parent 57c755c415
commit b0af12d4ce
2 changed files with 19 additions and 4 deletions

View file

@ -60,14 +60,28 @@ public:
} }
bool DelUser(const std::string &name, const std::string &attempt) bool DelUser(const std::string &name, const std::string &attempt)
{
{ {
std::shared_lock<std::shared_mutex> lock{size_l}; std::shared_lock<std::shared_mutex> lock{size_l};
return users.erase_if(name, [&attempt](const User &u) { return (XXH3_64bits(attempt.data(), attempt.size()) == u.password); }); bool state = users.erase_if(name, [&attempt](User &u) { return (XXH3_64bits(attempt.data(), attempt.size()) == u.password); });
}
if (state)
{
logs.erase_if(name, [](User &u) {})
}
return state;
} }
bool AdminDelUser(const std::string &name, const std::string &attempt) bool AdminDelUser(const std::string &name, const std::string &attempt)
{
{ {
std::shared_lock<std::shared_mutex> lock{size_l}; std::shared_lock<std::shared_mutex> lock{size_l};
return users.erase_if(name, [this, &attempt](const User &) { return (admin_pass == attempt); }); bool state = users.erase_if(name, [this, &attempt](const User &) { return (admin_pass == attempt); });
}
if (state)
{
logs.erase_if(name, [](User &u) {});
}
return state;
} }
bool SendFunds(const std::string &a_name, const std::string &b_name, uint_fast32_t amount, const std::string &attempt) bool SendFunds(const std::string &a_name, const std::string &b_name, uint_fast32_t amount, const std::string &attempt)

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
//24 bytes total
struct Transaction struct Transaction
{ {
std::string from = "", to = ""; std::string from = "", to = "";