🐎 checking if balance copied is non zero before modify call

This commit is contained in:
EntireTwix 2021-07-07 14:33:34 -07:00
parent bd87a14131
commit b0fdfc5f4f

View file

@ -233,7 +233,7 @@ BankResponse Bank::DelUser(const std::string &name) noexcept
uint32_t bal; uint32_t bal;
if (users.if_contains(name, [this, &bal](const User &u) { if (users.if_contains(name, [this, &bal](const User &u) {
bal = u.balance; bal = u.balance;
})) }) && bal)
{ {
users.modify_if(return_account, [ this, bal ](User & u)) users.modify_if(return_account, [ this, bal ](User & u))
{ {
@ -250,11 +250,11 @@ BankResponse Bank::DelUser(const std::string &name) noexcept
save_flag = true; save_flag = true;
#endif #endif
#endif #endif
return BankResponse{k200OK, "\"User deleted!\""}; return BankResponse(k200OK, "\"User deleted!\"");
} }
else else
{ {
return BankResponse{k404NotFound, "\"User not found\""}; return BankResponse(k404NotFound, "\"User not found\"");
} }
} }
void Bank::Save() void Bank::Save()