diff options
Diffstat (limited to 'src/network/verify_user.h')
| -rw-r--r-- | src/network/verify_user.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/network/verify_user.h b/src/network/verify_user.h new file mode 100644 index 000000000..6fc64d8a3 --- /dev/null +++ b/src/network/verify_user.h | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <string> | ||
| 7 | #include "common/logging/log.h" | ||
| 8 | |||
| 9 | namespace Network::VerifyUser { | ||
| 10 | |||
| 11 | struct UserData { | ||
| 12 | std::string username; | ||
| 13 | std::string display_name; | ||
| 14 | std::string avatar_url; | ||
| 15 | bool moderator = false; ///< Whether the user is a yuzu Moderator. | ||
| 16 | }; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * A backend used for verifying users and loading user data. | ||
| 20 | */ | ||
| 21 | class Backend { | ||
| 22 | public: | ||
| 23 | virtual ~Backend(); | ||
| 24 | |||
| 25 | /** | ||
| 26 | * Verifies the given token and loads the information into a UserData struct. | ||
| 27 | * @param verify_uid A GUID that may be used for verification. | ||
| 28 | * @param token A token that contains user data and verification data. The format and content is | ||
| 29 | * decided by backends. | ||
| 30 | */ | ||
| 31 | virtual UserData LoadUserData(const std::string& verify_uid, const std::string& token) = 0; | ||
| 32 | }; | ||
| 33 | |||
| 34 | /** | ||
| 35 | * A null backend where the token is ignored. | ||
| 36 | * No verification is performed here and the function returns an empty UserData. | ||
| 37 | */ | ||
| 38 | class NullBackend final : public Backend { | ||
| 39 | public: | ||
| 40 | ~NullBackend(); | ||
| 41 | |||
| 42 | UserData LoadUserData(const std::string& verify_uid, const std::string& token) override; | ||
| 43 | }; | ||
| 44 | |||
| 45 | } // namespace Network::VerifyUser | ||