Add custom login support
This commit is contained in:
parent
8e6c20dc99
commit
ebbfaf8713
@ -931,6 +931,8 @@ SET(LAUNCHER_SOURCES
|
|||||||
ui/dialogs/ProfileSetupDialog.h
|
ui/dialogs/ProfileSetupDialog.h
|
||||||
ui/dialogs/CopyInstanceDialog.cpp
|
ui/dialogs/CopyInstanceDialog.cpp
|
||||||
ui/dialogs/CopyInstanceDialog.h
|
ui/dialogs/CopyInstanceDialog.h
|
||||||
|
ui/dialogs/CustomLoginDialog.cpp
|
||||||
|
ui/dialogs/CustomLoginDialog.h
|
||||||
ui/dialogs/CustomMessageBox.cpp
|
ui/dialogs/CustomMessageBox.cpp
|
||||||
ui/dialogs/CustomMessageBox.h
|
ui/dialogs/CustomMessageBox.h
|
||||||
ui/dialogs/EditAccountDialog.cpp
|
ui/dialogs/EditAccountDialog.cpp
|
||||||
@ -1094,6 +1096,7 @@ qt_wrap_ui(LAUNCHER_UI
|
|||||||
ui/dialogs/MSALoginDialog.ui
|
ui/dialogs/MSALoginDialog.ui
|
||||||
ui/dialogs/OfflineLoginDialog.ui
|
ui/dialogs/OfflineLoginDialog.ui
|
||||||
ui/dialogs/ElybyLoginDialog.ui
|
ui/dialogs/ElybyLoginDialog.ui
|
||||||
|
ui/dialogs/CustomLoginDialog.ui
|
||||||
ui/dialogs/AboutDialog.ui
|
ui/dialogs/AboutDialog.ui
|
||||||
ui/dialogs/LoginDialog.ui
|
ui/dialogs/LoginDialog.ui
|
||||||
ui/dialogs/EditAccountDialog.ui
|
ui/dialogs/EditAccountDialog.ui
|
||||||
|
@ -377,6 +377,13 @@ bool AccountData::resumeStateFromV3(QJsonObject data) {
|
|||||||
mojangservicesToken = tokenFromJSONV3(data, "xrp-mc");
|
mojangservicesToken = tokenFromJSONV3(data, "xrp-mc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(type == AccountType::Custom) {
|
||||||
|
auto urlV = data.value("url");
|
||||||
|
if (urlV.isString()) {
|
||||||
|
customUrl = urlV.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
yggdrasilToken = tokenFromJSONV3(data, "ygg");
|
yggdrasilToken = tokenFromJSONV3(data, "ygg");
|
||||||
minecraftProfile = profileFromJSONV3(data, "profile");
|
minecraftProfile = profileFromJSONV3(data, "profile");
|
||||||
if(!entitlementFromJSONV3(data, minecraftEntitlement)) {
|
if(!entitlementFromJSONV3(data, minecraftEntitlement)) {
|
||||||
@ -418,6 +425,7 @@ QJsonObject AccountData::saveState() const {
|
|||||||
}
|
}
|
||||||
else if (type == AccountType::Custom) {
|
else if (type == AccountType::Custom) {
|
||||||
output["type"] = "Custom";
|
output["type"] = "Custom";
|
||||||
|
output["url"] = customUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenToJSONV3(output, yggdrasilToken, "ygg");
|
tokenToJSONV3(output, yggdrasilToken, "ygg");
|
||||||
|
@ -128,6 +128,7 @@ MinecraftAccountPtr MinecraftAccount::createCustom(const QString &username, cons
|
|||||||
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegularExpression("[{}-]"));
|
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegularExpression("[{}-]"));
|
||||||
account->data.minecraftEntitlement.ownsMinecraft = true;
|
account->data.minecraftEntitlement.ownsMinecraft = true;
|
||||||
account->data.minecraftEntitlement.canPlayMinecraft = true;
|
account->data.minecraftEntitlement.canPlayMinecraft = true;
|
||||||
|
account->data.customUrl = url;
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ void CustomProfileStep::perform() {
|
|||||||
|
|
||||||
// m_data->
|
// m_data->
|
||||||
|
|
||||||
|
qWarning() << "Url: " << m_data->customUrl;
|
||||||
|
|
||||||
QUrl url = QUrl(m_data->customUrl + "/session/profile/" + m_data->minecraftProfile.id);
|
QUrl url = QUrl(m_data->customUrl + "/session/profile/" + m_data->minecraftProfile.id);
|
||||||
QNetworkRequest req = QNetworkRequest(url);
|
QNetworkRequest req = QNetworkRequest(url);
|
||||||
AuthRequest *request = new AuthRequest(this);
|
AuthRequest *request = new AuthRequest(this);
|
||||||
|
@ -23,11 +23,12 @@ void CustomStep::rehydrate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CustomStep::perform() {
|
void CustomStep::perform() {
|
||||||
|
qWarning() << "url: " << m_url << " / " << m_data->customUrl;
|
||||||
if(m_password.size()) {
|
if(m_password.size()) {
|
||||||
m_yggdrasil->login(m_password, m_url + "/auth/");
|
m_yggdrasil->login(m_password, m_url + "/auth/");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_yggdrasil->refresh(m_url + "/auth/");
|
m_yggdrasil->refresh(m_data->customUrl + "/auth/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ void CustomStep::onAuthFailed() {
|
|||||||
// NOTE: soft error in the first step means 'offline'
|
// NOTE: soft error in the first step means 'offline'
|
||||||
if(state == AccountTaskState::STATE_FAILED_SOFT) {
|
if(state == AccountTaskState::STATE_FAILED_SOFT) {
|
||||||
state = AccountTaskState::STATE_OFFLINE;
|
state = AccountTaskState::STATE_OFFLINE;
|
||||||
errorMessage = tr("Custom user authentication ended with a network error. Is MutliFactor Auth current?");
|
errorMessage = tr("Custom user authentication ended with a network error. Is MutliFactor Auth correct?");
|
||||||
}
|
}
|
||||||
emit finished(state, errorMessage);
|
emit finished(state, errorMessage);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ void CustomLoginDialog::accept()
|
|||||||
ui->progressBar->setVisible(true);
|
ui->progressBar->setVisible(true);
|
||||||
|
|
||||||
// Setup the login task and start it
|
// Setup the login task and start it
|
||||||
m_account = MinecraftAccount::createCustom(ui->userTextBox->text());
|
m_account = MinecraftAccount::createCustom(ui->userTextBox->text(), ui->urlTextBox->text());
|
||||||
if (ui->mfaTextBox->text().length() > 0) {
|
if (ui->mfaTextBox->text().length() > 0) {
|
||||||
m_loginTask = m_account->loginCustom(ui->passTextBox->text() + ':' + ui->mfaTextBox->text(), ui->urlTextBox->text());
|
m_loginTask = m_account->loginCustom(ui->passTextBox->text() + ':' + ui->mfaTextBox->text(), ui->urlTextBox->text());
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ void AccountListPage::on_actionAddCustom_triggered()
|
|||||||
{
|
{
|
||||||
m_accounts->addAccount(account);
|
m_accounts->addAccount(account);
|
||||||
if (m_accounts->count() == 1) {
|
if (m_accounts->count() == 1) {
|
||||||
m_account->setDefaultAccount(account);
|
m_accounts->setDefaultAccount(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,7 +280,7 @@ void AccountListPage::updateButtonStates()
|
|||||||
bool accountIsReady = false;
|
bool accountIsReady = false;
|
||||||
bool accountIsOnline = false;
|
bool accountIsOnline = false;
|
||||||
bool accountIsElyby = false;
|
bool accountIsElyby = false;
|
||||||
bool AccountIsCustom = false;
|
bool accountIsCustom = false;
|
||||||
if (hasSelection)
|
if (hasSelection)
|
||||||
{
|
{
|
||||||
QModelIndex selected = selection.first();
|
QModelIndex selected = selection.first();
|
||||||
|
Loading…
Reference in New Issue
Block a user