diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp index 78cb0b8d2..97590e273 100644 --- a/launcher/minecraft/auth/steps/MSAStep.cpp +++ b/launcher/minecraft/auth/steps/MSAStep.cpp @@ -37,10 +37,12 @@ #include #include +#include #include #include "Application.h" #include "BuildConfig.h" +#include "FileSystem.h" class CustomOAuthOobReplyHandler : public QOAuthOobReplyHandler { Q_OBJECT @@ -61,9 +63,24 @@ MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(sile { m_clientId = APPLICATION->getMSAClientID(); - auto bv = new CustomOAuthOobReplyHandler(); + if (QCoreApplication::applicationFilePath().startsWith("/tmp/.mount_") || + QFile::exists(FS::PathCombine(APPLICATION->root(), "portable.txt"))) - oauth2.setReplyHandler(bv); + { + auto replyHandler = new QOAuthHttpServerReplyHandler(1337, this); + replyHandler->setCallbackText(R"XXX( + + Login Successful, redirecting... + + )XXX"); + oauth2.setReplyHandler(replyHandler); + } else { + oauth2.setReplyHandler(new CustomOAuthOobReplyHandler(this)); + } oauth2.setAuthorizationUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize")); oauth2.setAccessTokenUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/token")); oauth2.setScope("XboxLive.SignIn XboxLive.offline_access"); diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp index 59b45a0e4..04453499d 100644 --- a/launcher/ui/dialogs/MSALoginDialog.cpp +++ b/launcher/ui/dialogs/MSALoginDialog.cpp @@ -61,8 +61,7 @@ MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MS ui->code->setFont(font); connect(ui->copyCode, &QPushButton::clicked, this, [this] { QApplication::clipboard()->setText(ui->code->text()); }); - ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(150, 150))); - ui->title->setText(tr("Login to %1").arg(BuildConfig.LAUNCHER_DISPLAYNAME)); + ui->qr->setPixmap(QIcon((":/documents/login-qr.svg")).pixmap(QSize(150, 150), Qt::KeepAspectRatio)); connect(ui->loginButton, &QPushButton::clicked, this, [this] { if (m_url.isValid()) { if (!DesktopServices::openUrl(m_url)) { @@ -119,8 +118,11 @@ void MSALoginDialog::onTaskFailed(QString reason) processed += "
"; } } - auto task = qobject_cast(sender()); ui->status->setText(processed); + auto task = m_authflow_task; + if (task->failReason().isEmpty()) { + task = m_devicecode_task; + } if (task) { ui->loadingLabel->setText(task->getStatus()); } diff --git a/launcher/ui/dialogs/MSALoginDialog.ui b/launcher/ui/dialogs/MSALoginDialog.ui index 0d4b9f04a..bb9157aea 100644 --- a/launcher/ui/dialogs/MSALoginDialog.ui +++ b/launcher/ui/dialogs/MSALoginDialog.ui @@ -6,10 +6,16 @@ 0 0 - 770 - 331 + 440 + 430 + + + 0 + 430 + + Add Microsoft Account @@ -83,338 +89,246 @@ - + - + - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 16 - 75 - true - - - - Login to Prismlauncher - - - Qt::AlignCenter - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 250 - 40 - - - - Login with Microsoft - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + + Qt::Horizontal + + + + 40 + 20 + + + - - - - - - - - 0 - 0 - - - - 1 - - - Qt::Vertical - - - - - - - - - Or - - - Qt::AlignCenter - - - - - - - - - - 0 - 0 - - - - 1 - - - Qt::Vertical - - - - - - + + + + 250 + 40 + + + + Login with Microsoft + + + true + + - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 150 - 150 - - - - - 200 - 200 - - - - - - - true - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 30 - 75 - true - - - - IBeamCursor - - - CODE - - - Qt::AlignCenter - - - Qt::TextBrowserInteraction - - - - - - - Copy code to clipboard - - - - - - - .. - - - - 22 - 22 - - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - TextLabel - - - Qt::AlignCenter - - - true - - - Qt::TextBrowserInteraction - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + + + + Or + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 150 + 150 + + + + + 150 + 150 + + + + + + + true + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 30 + 75 + true + + + + IBeamCursor + + + CODE + + + Qt::AlignCenter + + + Qt::TextBrowserInteraction + + + + + + + Copy code to clipboard + + + + + + + .. + + + + 22 + 22 + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + TextLabel + + + Qt::AlignCenter + + + true + + + Qt::TextBrowserInteraction + + +