dedicated_room: Correctly handle token decoding
Correctly handle token decoding when '=' has been trimmed by the backend server. Co-Authored-By: liushuyu <liushuyu011@gmail.com>
This commit is contained in:
parent
2b6ac4463c
commit
27d7db1fae
|
@ -75,6 +75,17 @@ static constexpr char BanListMagic[] = "YuzuRoom-BanList-1";
|
||||||
|
|
||||||
static constexpr char token_delimiter{':'};
|
static constexpr char token_delimiter{':'};
|
||||||
|
|
||||||
|
static void PadToken(std::string& token) {
|
||||||
|
const auto remainder = token.size() % 3;
|
||||||
|
if (remainder == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < (3 - remainder); i++) {
|
||||||
|
token.push_back('=');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static std::string UsernameFromDisplayToken(const std::string& display_token) {
|
static std::string UsernameFromDisplayToken(const std::string& display_token) {
|
||||||
std::size_t outlen;
|
std::size_t outlen;
|
||||||
|
|
||||||
|
@ -300,6 +311,7 @@ int main(int argc, char** argv) {
|
||||||
if (username.empty()) {
|
if (username.empty()) {
|
||||||
LOG_INFO(Network, "Hosting a public room");
|
LOG_INFO(Network, "Hosting a public room");
|
||||||
Settings::values.web_api_url = web_api_url;
|
Settings::values.web_api_url = web_api_url;
|
||||||
|
PadToken(token);
|
||||||
Settings::values.yuzu_username = UsernameFromDisplayToken(token);
|
Settings::values.yuzu_username = UsernameFromDisplayToken(token);
|
||||||
username = Settings::values.yuzu_username.GetValue();
|
username = Settings::values.yuzu_username.GetValue();
|
||||||
Settings::values.yuzu_token = TokenFromDisplayToken(token);
|
Settings::values.yuzu_token = TokenFromDisplayToken(token);
|
||||||
|
|
Loading…
Reference in New Issue