summaryrefslogtreecommitdiffstats
path: root/src/web_service/verify_login.cpp
diff options
context:
space:
mode:
authorfearlessTobi <thm.frey@gmail.com>2018-09-16 20:05:51 +0200
committerfearlessTobi <thm.frey@gmail.com>2018-10-02 15:30:48 +0200
commit4d139943f2407144d5f8e3dc5a673f24850d43d0 (patch)
treebe24285a32c2b72b9756b69fd614f3d45c70ff41 /src/web_service/verify_login.cpp
parentAdd submodules (diff)
downloadyuzu-4d139943f2407144d5f8e3dc5a673f24850d43d0.tar
yuzu-4d139943f2407144d5f8e3dc5a673f24850d43d0.tar.gz
yuzu-4d139943f2407144d5f8e3dc5a673f24850d43d0.tar.bz2
yuzu-4d139943f2407144d5f8e3dc5a673f24850d43d0.tar.lz
yuzu-4d139943f2407144d5f8e3dc5a673f24850d43d0.tar.xz
yuzu-4d139943f2407144d5f8e3dc5a673f24850d43d0.tar.zst
yuzu-4d139943f2407144d5f8e3dc5a673f24850d43d0.zip
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..02e1b74f3
--- /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 "web_service/json.h"
+#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