Add support for 2FA on ely.by accounts (#64)

This commit is contained in:
fn2006 2023-06-09 13:42:13 +00:00 committed by GitHub
parent cc85b44ff2
commit 392822ec7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -50,6 +50,16 @@
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mfaTextBox">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>2FA Code (Optional)</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">