verify_user.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <string>
  5. #include "common/logging/log.h"
  6. namespace Network::VerifyUser {
  7. struct UserData {
  8. std::string username;
  9. std::string display_name;
  10. std::string avatar_url;
  11. bool moderator = false; ///< Whether the user is a yuzu Moderator.
  12. };
  13. /**
  14. * A backend used for verifying users and loading user data.
  15. */
  16. class Backend {
  17. public:
  18. virtual ~Backend();
  19. /**
  20. * Verifies the given token and loads the information into a UserData struct.
  21. * @param verify_uid A GUID that may be used for verification.
  22. * @param token A token that contains user data and verification data. The format and content is
  23. * decided by backends.
  24. */
  25. virtual UserData LoadUserData(const std::string& verify_uid, const std::string& token) = 0;
  26. };
  27. /**
  28. * A null backend where the token is ignored.
  29. * No verification is performed here and the function returns an empty UserData.
  30. */
  31. class NullBackend final : public Backend {
  32. public:
  33. ~NullBackend();
  34. UserData LoadUserData(const std::string& verify_uid, const std::string& token) override;
  35. };
  36. } // namespace Network::VerifyUser