summaryrefslogtreecommitdiffstats
path: root/logic/auth/AuthSession.cpp
blob: 8758bfbd3663bf0ab6f5eb50e8303fe44affa389 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#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;
}