diff options
| author | 2017-09-19 03:18:26 +0200 | |
|---|---|---|
| committer | 2017-09-18 21:18:26 -0400 | |
| commit | 28c726f20545744a3052a3e8a0a3bf5ff95a5042 (patch) | |
| tree | 496b81a9d2cefbdb3ac2ed12c6525ecd72610c14 /src/web_service/web_backend.h | |
| parent | Merge pull request #2906 from Subv/ns_new_framework (diff) | |
| download | yuzu-28c726f20545744a3052a3e8a0a3bf5ff95a5042.tar.gz yuzu-28c726f20545744a3052a3e8a0a3bf5ff95a5042.tar.xz yuzu-28c726f20545744a3052a3e8a0a3bf5ff95a5042.zip | |
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
Diffstat (limited to 'src/web_service/web_backend.h')
| -rw-r--r-- | src/web_service/web_backend.h | 16 |
1 files changed, 16 insertions, 0 deletions
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 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <functional> | ||
| 8 | #include <future> | ||
| 7 | #include <string> | 9 | #include <string> |
| 8 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 9 | 11 | ||
| @@ -20,4 +22,18 @@ namespace WebService { | |||
| 20 | void PostJson(const std::string& url, const std::string& data, bool allow_anonymous, | 22 | void PostJson(const std::string& url, const std::string& data, bool allow_anonymous, |
| 21 | const std::string& username = {}, const std::string& token = {}); | 23 | const std::string& username = {}, const std::string& token = {}); |
| 22 | 24 | ||
| 25 | /** | ||
| 26 | * Gets JSON from services.citra-emu.org. | ||
| 27 | * @param func A function that gets exectued when the json as a string is received | ||
| 28 | * @param url URL of the services.citra-emu.org endpoint to post data to. | ||
| 29 | * @param allow_anonymous If true, allow anonymous unauthenticated requests. | ||
| 30 | * @param username Citra username to use for authentication. | ||
| 31 | * @param token Citra token to use for authentication. | ||
| 32 | * @return future that holds the return value T of the func | ||
| 33 | */ | ||
| 34 | template <typename T> | ||
| 35 | std::future<T> GetJson(std::function<T(const std::string&)> func, const std::string& url, | ||
| 36 | bool allow_anonymous, const std::string& username = {}, | ||
| 37 | const std::string& token = {}); | ||
| 38 | |||
| 23 | } // namespace WebService | 39 | } // namespace WebService |