🚧 adding bindings for API

This commit is contained in:
EntireTwix 2021-04-04 21:41:47 -07:00
parent 769c0762f3
commit ef0e4859d1
2 changed files with 9 additions and 9 deletions

View file

@ -98,17 +98,17 @@ public:
});
return res;
}
int_fast8_t VerifyPassword(const std::string &name, const std::string &attempt) const
int_fast16_t VerifyPassword(const std::string &name, const std::string &attempt) const
{
int_fast8_t res = -1;
int_fast16_t res = -1;
users.if_contains(name, [&res, &attempt](const User &u) {
res = u.password == attempt;
});
return res;
}
int_fast8_t ChangePassword(const std::string &name, const std::string &attempt, std::string &&new_pass)
int_fast16_t ChangePassword(const std::string &name, const std::string &attempt, std::string &&new_pass)
{
int_fast8_t res = -1;
int_fast16_t res = -1;
users.modify_if(name, [&res, &attempt, &new_pass](User &u) {
res = (u.password == attempt);
if (res)
@ -164,4 +164,4 @@ public:
}
}
}
} Bank;
} bank;

View file

@ -21,10 +21,10 @@ int main(int argc, char **argv)
}
//Loading users from users.json
Bank.Load();
bank.Load();
//Admin Password
Bank.admin_pass = argv[1];
bank.admin_pass = argv[1];
//Auto Saving
const unsigned long saving_freq = std::stoul(argv[2]);
@ -34,12 +34,12 @@ int main(int argc, char **argv)
while (1)
{
std::this_thread::sleep_for(std::chrono::minutes(saving_freq));
Bank.Save();
bank.Save();
}
}).detach();
}
auto API = std::make_shared<BankFrontend>();
auto API = std::make_shared<BankF>();
app().addListener("0.0.0.0", 80).registerController(API).run();
return 0;