mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-11-20 08:10:11 +00:00
ffbc5bb62c
Allow the user to pick a player name for offline mode. Big auth refactor. Now using session objects instead of the accounts themselves. Sessions only last for one instance start and hold all the auth and player data.
31 lines
656 B
C++
31 lines
656 B
C++
#include "AuthSession.h"
|
|
#include <QJsonObject>
|
|
#include <QJsonArray>
|
|
#include <QJsonDocument>
|
|
#include <QStringList>
|
|
|
|
QString AuthSession::serializeUserProperties()
|
|
{
|
|
QJsonObject userAttrs;
|
|
for (auto key : u.properties.keys())
|
|
{
|
|
auto array = QJsonArray::fromStringList(u.properties.values(key));
|
|
userAttrs.insert(key, array);
|
|
}
|
|
QJsonDocument value(userAttrs);
|
|
return value.toJson(QJsonDocument::Compact);
|
|
|
|
}
|
|
|
|
bool AuthSession::MakeOffline(QString offline_playername)
|
|
{
|
|
if (status != PlayableOffline && status != PlayableOnline)
|
|
{
|
|
return false;
|
|
}
|
|
session = "-";
|
|
player_name = offline_playername;
|
|
status = PlayableOffline;
|
|
return true;
|
|
}
|