mirror of
https://github.com/PabloMK7/citra.git
synced 2025-09-10 04:40:05 +00:00
web_service: stop using std::future + callback style async
This commit is contained in:
parent
0a4d338ffa
commit
77c1f647cb
23 changed files with 329 additions and 457 deletions
|
@ -8,26 +8,20 @@
|
|||
|
||||
namespace WebService {
|
||||
|
||||
std::future<bool> VerifyLogin(std::string& username, std::string& token,
|
||||
const std::string& endpoint_url, std::function<void()> func) {
|
||||
auto get_func = [func, username](const std::string& reply) -> bool {
|
||||
func();
|
||||
bool VerifyLogin(const std::string& host, const std::string& username, const std::string& token) {
|
||||
Client client(host, username, token);
|
||||
auto reply = client.GetJson("/profile", false).returned_data;
|
||||
if (reply.empty()) {
|
||||
return false;
|
||||
}
|
||||
nlohmann::json json = nlohmann::json::parse(reply);
|
||||
const auto iter = json.find("username");
|
||||
|
||||
if (reply.empty()) {
|
||||
return false;
|
||||
}
|
||||
if (iter == json.end()) {
|
||||
return username.empty();
|
||||
}
|
||||
|
||||
nlohmann::json json = nlohmann::json::parse(reply);
|
||||
const auto iter = json.find("username");
|
||||
|
||||
if (iter == json.end()) {
|
||||
return username.empty();
|
||||
}
|
||||
|
||||
return username == *iter;
|
||||
};
|
||||
UpdateCoreJWT(true, username, token);
|
||||
return GetJson<bool>(get_func, endpoint_url, false);
|
||||
return username == *iter;
|
||||
}
|
||||
|
||||
} // namespace WebService
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue