summaryrefslogtreecommitdiff
path: root/src/web_service/verify_login.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-10-06 02:43:09 -0400
committerGitHub <noreply@github.com>2018-10-06 02:43:09 -0400
commitb8b90ce6e61329ebda226b9917ed961be3b80d1f (patch)
tree8e6b82419db7fb24eb5d8f06346a0a1228f9513c /src/web_service/verify_login.cpp
parent095c8d999b27bcd412ab91da27c56d014d8ddeb9 (diff)
parente4daf4bee522c046e5e01eeed2c5b12bd91f489e (diff)
Merge pull request #1332 from FearlessTobi/port-web-backend
Port web_service from Citra
Diffstat (limited to 'src/web_service/verify_login.cpp')
-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 @@
+// Copyright 2017 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include <json.hpp>
+#include "web_service/verify_login.h"
+#include "web_service/web_backend.h"
+
+namespace WebService {
+
+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 (iter == json.end()) {
+ return username.empty();
+ }
+
+ return username == *iter;
+}
+
+} // namespace WebService