MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / tokenToJSONV3

Function tokenToJSONV3

launcher/minecraft/auth/AccountData.cpp:45–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44namespace {
45void tokenToJSONV3(QJsonObject &parent, Katabasis::Token t, const char * tokenName) {
46 if(!t.persistent) {
47 return;
48 }
49 QJsonObject out;
50 if(t.issueInstant.isValid()) {
51 out["iat"] = QJsonValue(t.issueInstant.toMSecsSinceEpoch() / 1000);
52 }
53
54 if(t.notAfter.isValid()) {
55 out["exp"] = QJsonValue(t.notAfter.toMSecsSinceEpoch() / 1000);
56 }
57
58 bool save = false;
59 if(!t.token.isEmpty()) {
60 out["token"] = QJsonValue(t.token);
61 save = true;
62 }
63 if(!t.refresh_token.isEmpty()) {
64 out["refresh_token"] = QJsonValue(t.refresh_token);
65 save = true;
66 }
67 if(t.extra.size()) {
68 out["extra"] = QJsonObject::fromVariantMap(t.extra);
69 save = true;
70 }
71 if(save) {
72 parent[tokenName] = out;
73 }
74}
75
76Katabasis::Token tokenFromJSONV3(const QJsonObject &parent, const char * tokenName) {
77 Katabasis::Token out;

Callers 1

saveStateMethod · 0.85

Calls 3

isEmptyMethod · 0.80
isValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected