summaryrefslogtreecommitdiff
path: root/src/web_service/verify_login.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-10-06 02:43:09 -0400
committerGravatar GitHub2018-10-06 02:43:09 -0400
commitb8b90ce6e61329ebda226b9917ed961be3b80d1f (patch)
tree8e6b82419db7fb24eb5d8f06346a0a1228f9513c /src/web_service/verify_login.cpp
parentMerge pull request #1447 from lioncash/mutex (diff)
parentReview comments - part 5 (diff)
downloadyuzu-b8b90ce6e61329ebda226b9917ed961be3b80d1f.tar.gz
yuzu-b8b90ce6e61329ebda226b9917ed961be3b80d1f.tar.xz
yuzu-b8b90ce6e61329ebda226b9917ed961be3b80d1f.zip
Merge pull request #1332 from FearlessTobi/port-web-backend
Port web_service from Citra
Diffstat (limited to '')
-rw-r--r--src/web_service/verify_login.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/web_service/verify_login.cpp b/src/web_service/verify_login.cpp
new file mode 100644
index 000000000..124aa3863
--- /dev/null
+++ b/src/web_service/verify_login.cpp
@@ -0,0 +1,27 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <json.hpp>
6#include "web_service/verify_login.h"
7#include "web_service/web_backend.h"
8
9namespace WebService {
10
11bool VerifyLogin(const std::string& host, const std::string& username, const std::string& token) {
12 Client client(host, username, token);
13 auto reply = client.GetJson("/profile", false).returned_data;
14 if (reply.empty()) {
15 return false;
16 }
17 nlohmann::json json = nlohmann::json::parse(reply);
18 const auto iter = json.find("username");
19
20 if (iter == json.end()) {
21 return username.empty();
22 }
23
24 return username == *iter;
25}
26
27} // namespace WebService