verify_user.h 1.2 KB

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