From 392822ec7aab149e965842f2701d37b1ab643d3b Mon Sep 17 00:00:00 2001
From: fn2006 <92369097+fn2006@users.noreply.github.com>
Date: Fri, 9 Jun 2023 13:42:13 +0000
Subject: [PATCH] Add support for 2FA on ely.by accounts (#64)
---
launcher/minecraft/auth/steps/ElybyStep.cpp | 2 +-
launcher/ui/dialogs/ElybyLoginDialog.cpp | 8 +++++++-
launcher/ui/dialogs/ElybyLoginDialog.ui | 10 ++++++++++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/launcher/minecraft/auth/steps/ElybyStep.cpp b/launcher/minecraft/auth/steps/ElybyStep.cpp
index e81ebb09..618a5453 100644
--- a/launcher/minecraft/auth/steps/ElybyStep.cpp
+++ b/launcher/minecraft/auth/steps/ElybyStep.cpp
@@ -46,7 +46,7 @@ void ElybyStep::onAuthFailed() {
// NOTE: soft error in the first step means 'offline'
if(state == AccountTaskState::STATE_FAILED_SOFT) {
state = AccountTaskState::STATE_OFFLINE;
- errorMessage = tr("Ely.by user authentication ended with a network error.");
+ errorMessage = tr("Ely.by user authentication ended with a network error.\nIf you are using 2FA make sure to enter your auth code.");
}
emit finished(state, errorMessage);
}
diff --git a/launcher/ui/dialogs/ElybyLoginDialog.cpp b/launcher/ui/dialogs/ElybyLoginDialog.cpp
index bc22c4f0..1407cca0 100644
--- a/launcher/ui/dialogs/ElybyLoginDialog.cpp
+++ b/launcher/ui/dialogs/ElybyLoginDialog.cpp
@@ -43,7 +43,12 @@ void ElybyLoginDialog::accept()
// Setup the login task and start it
m_account = MinecraftAccount::createElyby(ui->userTextBox->text());
- m_loginTask = m_account->loginElyby(ui->passTextBox->text());
+ if (ui->mfaTextBox->text().length() > 0) {
+ m_loginTask = m_account->loginElyby(ui->passTextBox->text() + ':' + ui->mfaTextBox->text());
+ }
+ else {
+ m_loginTask = m_account->loginElyby(ui->passTextBox->text());
+ }
connect(m_loginTask.get(), &Task::failed, this, &ElybyLoginDialog::onTaskFailed);
connect(m_loginTask.get(), &Task::succeeded, this, &ElybyLoginDialog::onTaskSucceeded);
connect(m_loginTask.get(), &Task::status, this, &ElybyLoginDialog::onTaskStatus);
@@ -55,6 +60,7 @@ void ElybyLoginDialog::setUserInputsEnabled(bool enable)
{
ui->userTextBox->setEnabled(enable);
ui->passTextBox->setEnabled(enable);
+ ui->mfaTextBox->setEnabled(enable);
ui->buttonBox->setEnabled(enable);
}
diff --git a/launcher/ui/dialogs/ElybyLoginDialog.ui b/launcher/ui/dialogs/ElybyLoginDialog.ui
index 4b03ebf9..73a22a6f 100644
--- a/launcher/ui/dialogs/ElybyLoginDialog.ui
+++ b/launcher/ui/dialogs/ElybyLoginDialog.ui
@@ -50,6 +50,16 @@
+ -
+
+
+ QLineEdit::Password
+
+
+ 2FA Code (Optional)
+
+
+
-