mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-18 17:12:14 +11:00
🐎 massively reduced DelUser functions
This commit is contained in:
parent
1f6378ad92
commit
d263ae4966
1 changed files with 3 additions and 20 deletions
|
|
@ -35,31 +35,14 @@ public:
|
||||||
|
|
||||||
bool DelUser(const std::string &name, const std::string &attempt)
|
bool DelUser(const std::string &name, const std::string &attempt)
|
||||||
{
|
{
|
||||||
bool state = false;
|
return users.erase_if(name, [&attempt](const User &u) { return (attempt == u.password); });
|
||||||
//if password for user is correct, and user exists
|
|
||||||
users.if_contains(name, [&attempt, &state](const User &u) {
|
|
||||||
if (attempt == u.password)
|
|
||||||
{
|
|
||||||
state = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (state) //correct password
|
|
||||||
{
|
|
||||||
state = users.erase_if(name, [](const User &) { return true; });
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
}
|
||||||
bool AdminDelUser(const std::string &name, const std::string &attempt)
|
bool AdminDelUser(const std::string &name, const std::string &attempt)
|
||||||
{
|
{
|
||||||
bool state = (attempt == admin_pass);
|
return users.erase_if(name, [this, &attempt](const User &) { return (admin_pass == attempt); });
|
||||||
if (state)
|
|
||||||
{
|
|
||||||
state = users.erase_if(name, [&state](const User &) { state = true; return state; });
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int_fast64_t GetBal(const std::string &name)
|
int_fast64_t GetBal(const std::string &name) const
|
||||||
{
|
{
|
||||||
int_fast64_t res = -1;
|
int_fast64_t res = -1;
|
||||||
users.if_contains(name, [&res](const User &u) {
|
users.if_contains(name, [&res](const User &u) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue