made Contains return -1 instead of 0 in false case

This commit is contained in:
EntireTwix 2021-06-12 22:34:19 -07:00
parent 56bde9b341
commit 9b9d5cf430
4 changed files with 12 additions and 5 deletions

View file

@ -33,7 +33,7 @@
| Help | BankF/help | GET | false | the page you're looking at right now! |
| Ping | BankF/ping | GET | false | for pinging the server to see if its online |
| Close | BankF/admin/close | POST | true | saves and then closes the program if the supplied password matches the admin password |
| Contains | BankF/contains/{name} | GET | false | returns `true` or `false` depending on if the supplied user `{name}` exists |
| Contains | BankF/contains/{name} | GET | false | returns `1` if the supplied user `{name}` exists |
| AdminVerifyPass | BankF/admin/verify | GET | true | returns `1` if the password supplied in the header matches the admin password |
# User Management

View file

@ -41,7 +41,7 @@ public:
int_fast8_t SendFunds(const std::string &a_name, const std::string &b_name, uint32_t amount, const std::string &attempt);
bool Contains(const std::string &name) const;
int_fast8_t Contains(const std::string &name) const;
int_fast8_t AdminVerifyPass(const std::string &attempt);
int_fast8_t SetBal(const std::string &name, const std::string &attempt, uint32_t amount);

View file

@ -163,9 +163,16 @@ int_fast8_t Bank::SendFunds(const std::string &a_name, const std::string &b_name
}
}
bool Bank::Contains(const std::string &name) const
int_fast8_t Bank::Contains(const std::string &name) const
{
return users.contains(name);
if (users.contains(name))
{
return true;
}
else
{
return ErrorResponse::UserNotFound;
}
}
int_fast8_t Bank::AdminVerifyPass(const std::string &attempt)
{

File diff suppressed because one or more lines are too long