From 7c4da5771f8ed15a30ada5ed35a91ba50d162c10 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Sun, 4 Apr 2021 18:13:40 -0700 Subject: [PATCH] :sparkles: Contains --- include/bank.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/bank.hpp b/include/bank.hpp index 4cd5629..47cfefa 100644 --- a/include/bank.hpp +++ b/include/bank.hpp @@ -79,6 +79,10 @@ public: return state; } + bool Contains(const std::string &name) const + { + return users.if_contains(name, [](const User &) {}); + } int_fast64_t GetBal(const std::string &name) const { @@ -88,17 +92,17 @@ public: }); return res; } - int_fast32_t VerifyPassword(const std::string &name, const std::string &attempt) const + int_fast8_t VerifyPassword(const std::string &name, const std::string &attempt) const { - int_fast32_t res = -1; + int_fast8_t res = -1; users.if_contains(name, [&res, &attempt](const User &u) { res = u.password == attempt; }); return res; } - int_fast32_t ChangePassword(const std::string &name, const std::string &attempt, std::string &&new_pass) + int_fast8_t ChangePassword(const std::string &name, const std::string &attempt, std::string &&new_pass) { - int_fast32_t res = -1; + int_fast8_t res = -1; users.modify_if(name, [&res, &attempt, &new_pass](User &u) { res = (u.password == attempt); if (res)