2022-07-25 11:18:30 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2022-07-05 20:20:39 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
|
|
|
|
namespace Network::VerifyUser {
|
|
|
|
|
|
|
|
struct UserData {
|
|
|
|
std::string username;
|
|
|
|
std::string display_name;
|
|
|
|
std::string avatar_url;
|
2021-12-25 14:27:52 -05:00
|
|
|
bool moderator = false; ///< Whether the user is a yuzu Moderator.
|
2022-07-05 20:20:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A backend used for verifying users and loading user data.
|
|
|
|
*/
|
|
|
|
class Backend {
|
|
|
|
public:
|
|
|
|
virtual ~Backend();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies the given token and loads the information into a UserData struct.
|
2022-07-25 11:08:20 -04:00
|
|
|
* @param verify_uid A GUID that may be used for verification.
|
2022-07-05 20:20:39 -04:00
|
|
|
* @param token A token that contains user data and verification data. The format and content is
|
|
|
|
* decided by backends.
|
|
|
|
*/
|
2022-07-25 11:08:20 -04:00
|
|
|
virtual UserData LoadUserData(const std::string& verify_uid, const std::string& token) = 0;
|
2022-07-05 20:20:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A null backend where the token is ignored.
|
|
|
|
* No verification is performed here and the function returns an empty UserData.
|
|
|
|
*/
|
|
|
|
class NullBackend final : public Backend {
|
|
|
|
public:
|
|
|
|
~NullBackend();
|
|
|
|
|
2022-07-25 11:08:20 -04:00
|
|
|
UserData LoadUserData(const std::string& verify_uid, const std::string& token) override;
|
2022-07-05 20:20:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Network::VerifyUser
|