mirror of
https://github.com/Expand-sys/CCash
synced 2026-03-22 20:47:10 +11:00
🚧 adding bindings for API
This commit is contained in:
parent
769c0762f3
commit
ef0e4859d1
2 changed files with 9 additions and 9 deletions
|
|
@ -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;
|
||||
|
|
|
|||
8
main.cpp
8
main.cpp
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue