From 41328afb5852230e1f7c486c4ca20fbc9354a7f8 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 22 Aug 2017 23:06:56 -0400 Subject: web_backend: User config for username and token, support anonymous post. --- src/web_service/web_backend.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/web_service/web_backend.h') diff --git a/src/web_service/web_backend.h b/src/web_service/web_backend.h index 2753d3b68..08e384869 100644 --- a/src/web_service/web_backend.h +++ b/src/web_service/web_backend.h @@ -9,18 +9,6 @@ namespace WebService { -/** - * Gets the current username for accessing services.citra-emu.org. - * @returns Username as a string, empty if not set. - */ -const std::string& GetUsername(); - -/** - * Gets the current token for accessing services.citra-emu.org. - * @returns Token as a string, empty if not set. - */ -const std::string& GetToken(); - /** * Posts JSON to services.citra-emu.org. * @param url URL of the services.citra-emu.org endpoint to post data to. -- cgit v1.2.3 From 04bd0c957e583a518121626deb029f214cc98cf6 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 23 Aug 2017 21:09:34 -0400 Subject: web_services: Refactor to remove dependency on Core. --- src/web_service/web_backend.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/web_service/web_backend.h') diff --git a/src/web_service/web_backend.h b/src/web_service/web_backend.h index 08e384869..d17100398 100644 --- a/src/web_service/web_backend.h +++ b/src/web_service/web_backend.h @@ -13,7 +13,11 @@ namespace WebService { * Posts JSON to services.citra-emu.org. * @param url URL of the services.citra-emu.org endpoint to post data to. * @param data String of JSON data to use for the body of the POST request. + * @param allow_anonymous If true, allow anonymous unauthenticated requests. + * @param username Citra username to use for authentication. + * @param token Citra token to use for authentication. */ -void PostJson(const std::string& url, const std::string& data); +void PostJson(const std::string& url, const std::string& data, bool allow_anonymous, + const std::string& username = {}, const std::string& token = {}); } // namespace WebService -- cgit v1.2.3 From 28c726f20545744a3052a3e8a0a3bf5ff95a5042 Mon Sep 17 00:00:00 2001 From: B3n30 Date: Tue, 19 Sep 2017 03:18:26 +0200 Subject: WebService: Verify username and token (#2930) * WebService: Verify username and token; Log errors in PostJson * Fixup: added docstrings to the functions * Webservice: Added Icons to the verification, imrpved error detection in cpr, fixup nits * fixup: fmt warning --- src/web_service/web_backend.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/web_service/web_backend.h') diff --git a/src/web_service/web_backend.h b/src/web_service/web_backend.h index d17100398..a63c75d13 100644 --- a/src/web_service/web_backend.h +++ b/src/web_service/web_backend.h @@ -4,6 +4,8 @@ #pragma once +#include +#include #include #include "common/common_types.h" @@ -20,4 +22,18 @@ namespace WebService { void PostJson(const std::string& url, const std::string& data, bool allow_anonymous, const std::string& username = {}, const std::string& token = {}); +/** + * Gets JSON from services.citra-emu.org. + * @param func A function that gets exectued when the json as a string is received + * @param url URL of the services.citra-emu.org endpoint to post data to. + * @param allow_anonymous If true, allow anonymous unauthenticated requests. + * @param username Citra username to use for authentication. + * @param token Citra token to use for authentication. + * @return future that holds the return value T of the func + */ +template +std::future GetJson(std::function func, const std::string& url, + bool allow_anonymous, const std::string& username = {}, + const std::string& token = {}); + } // namespace WebService -- cgit v1.2.3