Skip to content

Commit

Permalink
Merge pull request #117 from unmojang/unmojang-elyby-migration
Browse files Browse the repository at this point in the history
Smooth Ely.by -> authlib-injector migration
  • Loading branch information
fn2006 authored Nov 15, 2023
2 parents c5dad68 + be8c8ad commit 18db32d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
26 changes: 20 additions & 6 deletions launcher/minecraft/auth/AccountData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,17 @@ bool AccountData::resumeStateFromV3(QJsonObject data)
return false;
}
auto typeS = typeV.toString();
bool needsElyByMigration = false;
if (typeS == "MSA") {
type = AccountType::MSA;
} else if (typeS == "Mojang") {
type = AccountType::Mojang;
} else if (typeS == "AuthlibInjector") {
type = AccountType::AuthlibInjector;
} else if (typeS == "Elyby") {
// Migrate legacy Ely.by accounts to authlib-injector accounts
type = AccountType::AuthlibInjector;
needsElyByMigration = true;
} else if (typeS == "Offline") {
type = AccountType::Offline;
} else {
Expand All @@ -367,12 +372,21 @@ bool AccountData::resumeStateFromV3(QJsonObject data)
}

if (type == AccountType::AuthlibInjector) {
customAuthServerUrl = data.value("customAuthServerUrl").toString();
customAccountServerUrl = data.value("customAccountServerUrl").toString();
customSessionServerUrl = data.value("customSessionServerUrl").toString();
customServicesServerUrl = data.value("customServicesServerUrl").toString();
authlibInjectorUrl = data.value("authlibInjectorUrl").toString();
authlibInjectorMetadata = data.value("authlibInjectorMetadata").toString();
if (needsElyByMigration) {
customAuthServerUrl = "https://authserver.ely.by/api/authlib-injector/authserver";
customAccountServerUrl = "https://authserver.ely.by/api/authlib-injector/api";
customSessionServerUrl = "https://authserver.ely.by/api/authlib-injector/sessionserver";
customServicesServerUrl = "https://authserver.ely.by/api/authlib-injector/minecraftservices";
authlibInjectorUrl = "https://authserver.ely.by/api/authlib-injector";
authlibInjectorMetadata = "";
} else {
customAuthServerUrl = data.value("customAuthServerUrl").toString();
customAccountServerUrl = data.value("customAccountServerUrl").toString();
customSessionServerUrl = data.value("customSessionServerUrl").toString();
customServicesServerUrl = data.value("customServicesServerUrl").toString();
authlibInjectorUrl = data.value("authlibInjectorUrl").toString();
authlibInjectorMetadata = data.value("authlibInjectorMetadata").toString();
}
}

if (type == AccountType::MSA) {
Expand Down
3 changes: 3 additions & 0 deletions launcher/minecraft/auth/MinecraftAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ bool MinecraftAccount::shouldRefresh() const
if (isInUse()) {
return false;
}
if (data.type == AccountType::AuthlibInjector && data.authlibInjectorMetadata == "") {
return true;
}
switch (data.validity_) {
case Katabasis::Validity::Certain: {
break;
Expand Down

0 comments on commit 18db32d

Please sign in to comment.