Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auth server column to account list #139

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions launcher/minecraft/auth/AccountData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ bool AccountData::resumeStateFromV3(QJsonObject data)
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";
customAuthlibInjectorUrl = "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();
customAuthlibInjectorUrl = data.value("authlibInjectorUrl").toString();
authlibInjectorMetadata = data.value("authlibInjectorMetadata").toString();
}
}
Expand Down Expand Up @@ -383,7 +383,7 @@ QJsonObject AccountData::saveState() const
output["customAccountServerUrl"] = customAccountServerUrl;
output["customSessionServerUrl"] = customSessionServerUrl;
output["customServicesServerUrl"] = customServicesServerUrl;
output["authlibInjectorUrl"] = authlibInjectorUrl;
output["authlibInjectorUrl"] = customAuthlibInjectorUrl;
output["authlibInjectorMetadata"] = authlibInjectorMetadata;
}

Expand Down Expand Up @@ -425,6 +425,15 @@ QString AccountData::sessionServerUrl() const
}
}

QString AccountData::authlibInjectorUrl() const
{
if (usesCustomApiServers()) {
return customAuthlibInjectorUrl;
} else {
return QString();
}
}

QString AccountData::servicesServerUrl() const
{
if (usesCustomApiServers()) {
Expand Down
3 changes: 2 additions & 1 deletion launcher/minecraft/auth/AccountData.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ struct AccountData {
QString accountServerUrl() const;
QString sessionServerUrl() const;
QString servicesServerUrl() const;
QString authlibInjectorUrl() const;

//! userName for Mojang accounts, gamertag for MSA
QString accountDisplayString() const;
Expand Down Expand Up @@ -113,7 +114,7 @@ struct AccountData {
QString customAccountServerUrl;
QString customSessionServerUrl;
QString customServicesServerUrl;
QString authlibInjectorUrl;
QString customAuthlibInjectorUrl;
QString authlibInjectorMetadata;

QString msaClientID;
Expand Down
8 changes: 8 additions & 0 deletions launcher/minecraft/auth/AccountList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ QVariant AccountList::data(const QModelIndex& index, int role) const
}
}

case AuthServerColumn: {
return account->authlibInjectorUrl();
}

case MigrationColumn: {
if (!account->isMojang()) {
return tr("N/A", "Can Migrate");
Expand Down Expand Up @@ -379,6 +383,8 @@ QVariant AccountList::headerData(int section, [[maybe_unused]] Qt::Orientation o
return tr("Type");
case StatusColumn:
return tr("Status");
case AuthServerColumn:
return tr("Server");
default:
return QVariant();
}
Expand All @@ -393,6 +399,8 @@ QVariant AccountList::headerData(int section, [[maybe_unused]] Qt::Orientation o
return tr("Type of the account (MSA or Offline)");
case StatusColumn:
return tr("Current status of the account.");
case AuthServerColumn:
return tr("Auth server the account is using.");
default:
return QVariant();
}
Expand Down
1 change: 1 addition & 0 deletions launcher/minecraft/auth/AccountList.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class AccountList : public QAbstractListModel {
MigrationColumn,
TypeColumn,
StatusColumn,
AuthServerColumn,

NUM_COLUMNS
};
Expand Down
4 changes: 2 additions & 2 deletions launcher/minecraft/auth/MinecraftAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ MinecraftAccountPtr MinecraftAccount::createFromUsernameAuthlibInjector(const QS
account->data.minecraftEntitlement.ownsMinecraft = true;
account->data.minecraftEntitlement.canPlayMinecraft = true;

account->data.authlibInjectorUrl = authlibInjectorUrl;
account->data.customAuthlibInjectorUrl = authlibInjectorUrl;
account->data.customAuthServerUrl = authlibInjectorUrl + "/authserver";
account->data.customAccountServerUrl = authlibInjectorUrl + "/api";
account->data.customSessionServerUrl = authlibInjectorUrl + "/sessionserver";
Expand Down Expand Up @@ -342,7 +342,7 @@ void MinecraftAccount::fillSession(AuthSessionPtr session)
}

// API URLs
session->authlib_injector_url = data.authlibInjectorUrl;
session->authlib_injector_url = data.authlibInjectorUrl();
session->auth_server_url = data.authServerUrl();
session->account_server_url = data.accountServerUrl();
session->session_server_url = data.sessionServerUrl();
Expand Down
2 changes: 1 addition & 1 deletion launcher/minecraft/auth/MinecraftAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class MinecraftAccount : public QObject, public Usable {
public: /* queries */
QString internalId() const { return data.internalId; }

QString authlibInjectorUrl() const { return data.authlibInjectorUrl; }
QString authlibInjectorUrl() const { return data.authlibInjectorUrl(); }

QString authServerUrl() const { return data.authServerUrl(); }

Expand Down
4 changes: 2 additions & 2 deletions launcher/minecraft/auth/steps/AuthlibInjectorMetadataStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ QString AuthlibInjectorMetadataStep::describe()

void AuthlibInjectorMetadataStep::perform()
{
if (m_data->authlibInjectorUrl == "") {
if (m_data->customAuthlibInjectorUrl == "") {
emit finished(AccountTaskState::STATE_WORKING, tr("Account has no authlib-injector URL."));
return;
}
QNetworkRequest request = QNetworkRequest(m_data->authlibInjectorUrl);
QNetworkRequest request = QNetworkRequest(m_data->customAuthlibInjectorUrl);
AuthRequest* requestor = new AuthRequest(this);
connect(requestor, &AuthRequest::finished, this, &AuthlibInjectorMetadataStep::onRequestDone);
requestor->get(request);
Expand Down
1 change: 1 addition & 0 deletions launcher/ui/pages/global/AccountListPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ AccountListPage::AccountListPage(QWidget* parent) : QMainWindow(parent), ui(new
ui->listView->header()->setSectionResizeMode(AccountList::VListColumns::NameColumn, QHeaderView::Stretch);
ui->listView->header()->setSectionResizeMode(AccountList::VListColumns::TypeColumn, QHeaderView::ResizeToContents);
ui->listView->header()->setSectionResizeMode(AccountList::VListColumns::StatusColumn, QHeaderView::ResizeToContents);
ui->listView->header()->setSectionResizeMode(AccountList::VListColumns::AuthServerColumn, QHeaderView::ResizeToContents);
ui->listView->setSelectionMode(QAbstractItemView::SingleSelection);

// Expand the account column
Expand Down