Add back device code flow

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2024-05-16 21:58:25 +03:00
parent 2a58fb0ac5
commit 09c0c11033
14 changed files with 481 additions and 36 deletions

View File

@ -119,11 +119,11 @@ QPixmap MinecraftAccount::getFace() const
return skin.scaled(64, 64, Qt::KeepAspectRatio);
}
shared_qobject_ptr<AuthFlow> MinecraftAccount::login()
shared_qobject_ptr<AuthFlow> MinecraftAccount::login(bool useDeviceCode)
{
Q_ASSERT(m_currentTask.get() == nullptr);
m_currentTask.reset(new AuthFlow(&data, false, this));
m_currentTask.reset(new AuthFlow(&data, useDeviceCode ? AuthFlow::Action::DeviceCode : AuthFlow::Action::Login, this));
connect(m_currentTask.get(), &Task::succeeded, this, &MinecraftAccount::authSucceeded);
connect(m_currentTask.get(), &Task::failed, this, &MinecraftAccount::authFailed);
connect(m_currentTask.get(), &Task::aborted, this, [this] { authFailed(tr("Aborted")); });
@ -137,7 +137,7 @@ shared_qobject_ptr<AuthFlow> MinecraftAccount::refresh()
return m_currentTask;
}
m_currentTask.reset(new AuthFlow(&data, true, this));
m_currentTask.reset(new AuthFlow(&data, AuthFlow::Action::Refresh, this));
connect(m_currentTask.get(), &Task::succeeded, this, &MinecraftAccount::authSucceeded);
connect(m_currentTask.get(), &Task::failed, this, &MinecraftAccount::authFailed);