update login flow

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2024-06-12 00:34:39 +03:00
parent 6b1c4981e7
commit c4a65dd861
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
15 changed files with 421 additions and 166 deletions

View File

@ -48,7 +48,6 @@
#include <BaseInstance.h> #include <BaseInstance.h>
#include "minecraft/launch/MinecraftServerTarget.h" #include "minecraft/launch/MinecraftServerTarget.h"
#include "ui/themes/CatPack.h"
class LaunchController; class LaunchController;
class LocalPeer; class LocalPeer;
@ -193,6 +192,8 @@ class Application : public QApplication {
void globalSettingsClosed(); void globalSettingsClosed();
int currentCatChanged(int index); int currentCatChanged(int index);
void oauthReplyRecieved(QVariantMap);
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
void clickedOnDock(); void clickedOnDock();
#endif #endif

View File

@ -59,6 +59,9 @@ void AuthFlow::executeTask()
void AuthFlow::nextStep() void AuthFlow::nextStep()
{ {
if (!Task::isRunning()) {
return;
}
if (m_steps.size() == 0) { if (m_steps.size() == 0) {
// we got to the end without an incident... assume this is all. // we got to the end without an incident... assume this is all.
m_currentStep.reset(); m_currentStep.reset();
@ -144,3 +147,10 @@ bool AuthFlow::changeState(AccountTaskState newState, QString reason)
} }
} }
} }
bool AuthFlow::abort()
{
emitAborted();
if (m_currentStep)
m_currentStep->abort();
return true;
}

View File

@ -24,6 +24,9 @@ class AuthFlow : public Task {
AccountTaskState taskState() { return m_taskState; } AccountTaskState taskState() { return m_taskState; }
public slots:
bool abort() override;
signals: signals:
void authorizeWithBrowser(const QUrl& url); void authorizeWithBrowser(const QUrl& url);
void authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn); void authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn);

View File

@ -34,6 +34,7 @@ class AuthStep : public QObject {
public slots: public slots:
virtual void perform() = 0; virtual void perform() = 0;
virtual void abort() {}
signals: signals:
void finished(AccountTaskState resultingState, QString message); void finished(AccountTaskState resultingState, QString message);

View File

@ -51,7 +51,7 @@ class MSADeviceCodeStep : public AuthStep {
QString describe() override; QString describe() override;
public slots: public slots:
void abort(); void abort() override;
signals: signals:
void authorizeWithBrowser(QString url, QString code, int expiresIn); void authorizeWithBrowser(QString url, QString code, int expiresIn);

View File

@ -35,22 +35,35 @@
#include "MSAStep.h" #include "MSAStep.h"
#include <QtNetworkAuth/qoauthhttpserverreplyhandler.h>
#include <QAbstractOAuth2> #include <QAbstractOAuth2>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QOAuthOobReplyHandler>
#include "Application.h" #include "Application.h"
#include "BuildConfig.h"
class CustomOAuthOobReplyHandler : public QOAuthOobReplyHandler {
Q_OBJECT
public:
explicit CustomOAuthOobReplyHandler(QObject* parent = nullptr) : QOAuthOobReplyHandler(parent)
{
connect(APPLICATION, &Application::oauthReplyRecieved, this, &QOAuthOobReplyHandler::callbackReceived);
}
~CustomOAuthOobReplyHandler() override
{
disconnect(APPLICATION, &Application::oauthReplyRecieved, this, &QOAuthOobReplyHandler::callbackReceived);
}
QString callback() const override { return BuildConfig.LAUNCHER_APP_BINARY_NAME + "://oauth"; }
};
MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(silent) MSAStep::MSAStep(AccountData* data, bool silent) : AuthStep(data), m_silent(silent)
{ {
m_clientId = APPLICATION->getMSAClientID(); m_clientId = APPLICATION->getMSAClientID();
auto replyHandler = new QOAuthHttpServerReplyHandler(1337, this); auto bv = new CustomOAuthOobReplyHandler();
replyHandler->setCallbackText(
" <iframe src=\"https://prismlauncher.org/successful-login\" title=\"PrismLauncher Microsoft login\" style=\"position:fixed; " oauth2.setReplyHandler(bv);
"top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; "
"z-index:999999;\"/> ");
oauth2.setReplyHandler(replyHandler);
oauth2.setAuthorizationUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize")); 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.setAccessTokenUrl(QUrl("https://login.microsoftonline.com/consumers/oauth2/v2.0/token"));
oauth2.setScope("XboxLive.SignIn XboxLive.offline_access"); oauth2.setScope("XboxLive.SignIn XboxLive.offline_access");
@ -106,3 +119,5 @@ void MSAStep::perform()
oauth2.grant(); oauth2.grant();
} }
} }
#include "MSAStep.moc"

View File

@ -2,6 +2,7 @@
<RCC version="1.0"> <RCC version="1.0">
<qresource prefix="/documents"> <qresource prefix="/documents">
<file>../../../COPYING.md</file> <file>../../../COPYING.md</file>
<file>login-qr.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@ -996,6 +996,14 @@ void MainWindow::processURLs(QList<QUrl> urls)
dlUrlDialod.execWithTask(job.get()); dlUrlDialod.execWithTask(job.get());
} }
} else if (url.scheme() == BuildConfig.LAUNCHER_APP_BINARY_NAME) {
QVariantMap receivedData;
const QUrlQuery query(url.query());
const auto items = query.queryItems();
for (auto it = items.begin(), end = items.end(); it != end; ++it)
receivedData.insert(it->first, it->second);
emit APPLICATION->oauthReplyRecieved(receivedData);
continue;
} else { } else {
dl_url = url; dl_url = url;
} }

View File

@ -34,6 +34,8 @@
*/ */
#include "MSALoginDialog.h" #include "MSALoginDialog.h"
#include "Application.h"
#include "ui_MSALoginDialog.h" #include "ui_MSALoginDialog.h"
#include "DesktopServices.h" #include "DesktopServices.h"
@ -41,6 +43,7 @@
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
#include <QPixmap>
#include <QUrl> #include <QUrl>
#include <QtWidgets/QPushButton> #include <QtWidgets/QPushButton>
@ -48,13 +51,18 @@ MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MS
{ {
ui->setupUi(this); ui->setupUi(this);
ui->cancel->setEnabled(false); // make font monospace
ui->link->setVisible(false); QFont font;
ui->copy->setVisible(false); font.setPixelSize(ui->code->fontInfo().pixelSize());
ui->progressBar->setVisible(false); font.setFamily(APPLICATION->settings()->get("ConsoleFont").toString());
font.setStyleHint(QFont::Monospace);
font.setFixedPitch(true);
ui->code->setFont(font);
connect(ui->cancel, &QPushButton::pressed, this, &QDialog::reject); ui->buttonBox->button(QDialogButtonBox::Help)->setDefault(false);
connect(ui->copy, &QPushButton::pressed, this, &MSALoginDialog::copyUrl);
connect(ui->copyCode, &QPushButton::clicked, this, [this] { QApplication::clipboard()->setText(ui->code->text()); });
ui->qr->setPixmap(QPixmap(":/documents/login-qr.png"));
} }
int MSALoginDialog::exec() int MSALoginDialog::exec()
@ -63,12 +71,12 @@ int MSALoginDialog::exec()
m_account = MinecraftAccount::createBlankMSA(); m_account = MinecraftAccount::createBlankMSA();
m_task = m_account->login(m_using_device_code); m_task = m_account->login(m_using_device_code);
connect(m_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed); connect(m_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed);
connect(m_task.get(), &Task::succeeded, this, &MSALoginDialog::onTaskSucceeded); connect(m_task.get(), &Task::succeeded, this, &QDialog::accept);
connect(m_task.get(), &Task::aborted, this, &MSALoginDialog::reject);
connect(m_task.get(), &Task::status, this, &MSALoginDialog::onTaskStatus); connect(m_task.get(), &Task::status, this, &MSALoginDialog::onTaskStatus);
connect(m_task.get(), &AuthFlow::authorizeWithBrowser, this, &MSALoginDialog::authorizeWithBrowser); connect(m_task.get(), &AuthFlow::authorizeWithBrowser, this, &MSALoginDialog::authorizeWithBrowser);
connect(m_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra); connect(m_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra);
connect(ui->cancel, &QPushButton::pressed, m_task.get(), &Task::abort); connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_task.get(), &Task::abort);
connect(&m_external_timer, &QTimer::timeout, this, &MSALoginDialog::externalLoginTick);
m_task->start(); m_task->start();
return QDialog::exec(); return QDialog::exec();
@ -79,9 +87,10 @@ MSALoginDialog::~MSALoginDialog()
delete ui; delete ui;
} }
void MSALoginDialog::onTaskFailed(const QString& reason) void MSALoginDialog::onTaskFailed(QString reason)
{ {
// Set message // Set message
ui->stackedWidget->setCurrentIndex(0);
auto lines = reason.split('\n'); auto lines = reason.split('\n');
QString processed; QString processed;
for (auto line : lines) { for (auto line : lines) {
@ -91,91 +100,55 @@ void MSALoginDialog::onTaskFailed(const QString& reason)
processed += "<br />"; processed += "<br />";
} }
} }
ui->message->setText(processed); ui->status->setText(processed);
ui->loadingLabel->setText(m_task->getStatus());
disconnect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_task.get(), &Task::abort);
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &MSALoginDialog::reject);
} }
void MSALoginDialog::onTaskSucceeded() void MSALoginDialog::authorizeWithBrowser(const QUrl& url)
{ {
QDialog::accept(); ui->stackedWidget->setCurrentIndex(2);
DesktopServices::openUrl(url);
const auto uri = url.toString();
const auto linkString = QString("<a href=\"%1\">%2</a>").arg(uri, uri);
ui->urlInfo->setText(
tr("Browser opened to complete the login process."
"<br /><br />"
"If your browser hasn't opened, please manually open the following link and choose your account:</p>"));
ui->url->setText(linkString);
} }
void MSALoginDialog::onTaskStatus(const QString& status) void MSALoginDialog::authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn)
{ {
ui->message->setText(status); ui->stackedWidget->setCurrentIndex(1);
ui->cancel->setEnabled(false);
ui->link->setVisible(false); const auto linkString = QString("<a href=\"%1\">%2</a>").arg(url, url);
ui->copy->setVisible(false); ui->code->setText(code);
ui->progressBar->setVisible(false); ui->codeInfo->setText(tr("<p>Enter this code into %1 and choose your account.</p>").arg(linkString));
const auto isDefaultUrl = url == "https://www.microsoft.com/link";
ui->qr->setVisible(isDefaultUrl);
if (isDefaultUrl && !code.isEmpty()) {
url += QString("?otc=%1").arg(code);
}
DesktopServices::openUrl(url);
}
void MSALoginDialog::onTaskStatus(QString status)
{
ui->stackedWidget->setCurrentIndex(0);
ui->status->setText(status);
} }
// Public interface // Public interface
MinecraftAccountPtr MSALoginDialog::newAccount(QWidget* parent, QString msg, bool usingDeviceCode) MinecraftAccountPtr MSALoginDialog::newAccount(QWidget* parent, bool usingDeviceCode)
{ {
MSALoginDialog dlg(parent); MSALoginDialog dlg(parent);
dlg.m_using_device_code = usingDeviceCode; dlg.m_using_device_code = usingDeviceCode;
dlg.ui->message->setText(msg);
if (dlg.exec() == QDialog::Accepted) { if (dlg.exec() == QDialog::Accepted) {
return dlg.m_account; return dlg.m_account;
} }
return nullptr; return nullptr;
} }
void MSALoginDialog::authorizeWithBrowser(const QUrl& url)
{
ui->cancel->setEnabled(true);
ui->link->setVisible(true);
ui->copy->setVisible(true);
DesktopServices::openUrl(url);
ui->link->setText(url.toDisplayString());
ui->message->setText(
tr("Browser opened to complete the login process."
"<br /><br />"
"If your browser hasn't opened, please manually open the below link in your browser:"));
}
void MSALoginDialog::copyUrl()
{
QClipboard* cb = QApplication::clipboard();
cb->setText(ui->link->text());
}
void MSALoginDialog::authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn)
{
m_external_elapsed = 0;
m_external_timeout = expiresIn;
m_external_timer.setInterval(1000);
m_external_timer.setSingleShot(false);
m_external_timer.start();
ui->progressBar->setMaximum(expiresIn);
ui->progressBar->setValue(m_external_elapsed);
QString linkString = QString("<a href=\"%1\">%2</a>").arg(url, url);
if (url == "https://www.microsoft.com/link" && !code.isEmpty()) {
url += QString("?otc=%1").arg(code);
ui->message->setText(tr("<p>Please login in the opened browser. If no browser was opened, please open up %1 in "
"a browser and put in the code <b>%2</b> to proceed with login.</p>")
.arg(linkString, code));
} else {
ui->message->setText(
tr("<p>Please open up %1 in a browser and put in the code <b>%2</b> to proceed with login.</p>").arg(linkString, code));
}
ui->cancel->setEnabled(true);
ui->link->setVisible(true);
ui->copy->setVisible(true);
ui->progressBar->setVisible(true);
DesktopServices::openUrl(url);
ui->link->setText(code);
}
void MSALoginDialog::externalLoginTick()
{
m_external_elapsed++;
ui->progressBar->setValue(m_external_elapsed);
ui->progressBar->repaint();
if (m_external_elapsed >= m_external_timeout) {
m_external_timer.stop();
}
}

View File

@ -32,29 +32,22 @@ class MSALoginDialog : public QDialog {
public: public:
~MSALoginDialog(); ~MSALoginDialog();
static MinecraftAccountPtr newAccount(QWidget* parent, QString message, bool usingDeviceCode = false); static MinecraftAccountPtr newAccount(QWidget* parent, bool usingDeviceCode = false);
int exec() override; int exec() override;
private: private:
explicit MSALoginDialog(QWidget* parent = 0); explicit MSALoginDialog(QWidget* parent = 0);
protected slots: protected slots:
void onTaskFailed(const QString& reason); void onTaskFailed(QString reason);
void onTaskSucceeded(); void onTaskStatus(QString status);
void onTaskStatus(const QString& status);
void authorizeWithBrowser(const QUrl& url); void authorizeWithBrowser(const QUrl& url);
void authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn); void authorizeWithBrowserWithExtra(QString url, QString code, int expiresIn);
void copyUrl();
void externalLoginTick();
private: private:
Ui::MSALoginDialog* ui; Ui::MSALoginDialog* ui;
MinecraftAccountPtr m_account; MinecraftAccountPtr m_account;
shared_qobject_ptr<AuthFlow> m_task; shared_qobject_ptr<AuthFlow> m_task;
int m_external_elapsed;
int m_external_timeout;
QTimer m_external_timer;
bool m_using_device_code = false; bool m_using_device_code = false;
}; };

View File

@ -6,39 +6,282 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>491</width> <width>500</width>
<height>208</height> <height>300</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Add Microsoft Account</string> <string>Add Microsoft Account</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="message"> <widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy"> <property name="currentIndex">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding"> <number>2</number>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<widget class="QWidget" name="loadingPage">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="loadingLabel">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Please wait...</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="status">
<property name="text">
<string>Status</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="codePage">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="code">
<property name="font">
<font>
<pointsize>40</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string>CODE</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="copyCode">
<property name="toolTip">
<string>Copy code to clipboard</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="copy">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="codeInfo">
<property name="font">
<font>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Information</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="qr">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>500</width> <width>100</width>
<height>500</height> <height>100</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string notr="true"/> <string/>
</property> </property>
<property name="textFormat"> <property name="pixmap">
<enum>Qt::RichText</enum> <pixmap>:/assets/login-qr.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="urlPage">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="urlInfo">
<property name="font">
<font>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Information</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
@ -46,47 +289,51 @@
<property name="openExternalLinks"> <property name="openExternalLinks">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="url">
<property name="text">
<string>url</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="linkLayout"> <spacer name="verticalSpacer_8">
<item> <property name="orientation">
<widget class="QLineEdit" name="link"> <enum>Qt::Vertical</enum>
<property name="readOnly">
<bool>false</bool>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
</item> <size>
<item> <width>20</width>
<widget class="QPushButton" name="copy"> <height>40</height>
<property name="text"> </size>
<string/>
</property> </property>
<property name="icon"> </spacer>
<iconset theme="copy">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </widget>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="cancel"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="text"> <property name="standardButtons">
<string>Cancel</string> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -134,15 +134,14 @@ void AccountListPage::on_actionAddMicrosoft_triggered()
box.setWindowTitle(tr("Add account")); box.setWindowTitle(tr("Add account"));
box.setText(tr("How do you want to login?")); box.setText(tr("How do you want to login?"));
box.setIcon(QMessageBox::Question); box.setIcon(QMessageBox::Question);
auto deviceCode = box.addButton(tr("Legacy"), QMessageBox::ButtonRole::YesRole); auto deviceCode = box.addButton(tr("Remote"), QMessageBox::ButtonRole::YesRole);
auto authCode = box.addButton(tr("Recommended"), QMessageBox::ButtonRole::NoRole); auto authCode = box.addButton(tr("Recommended"), QMessageBox::ButtonRole::NoRole);
auto cancel = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::RejectRole); auto cancel = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::RejectRole);
box.setDefaultButton(authCode); box.setDefaultButton(authCode);
box.exec(); box.exec();
if ((box.clickedButton() != deviceCode && box.clickedButton() != authCode) || box.clickedButton() == cancel) if ((box.clickedButton() != deviceCode && box.clickedButton() != authCode) || box.clickedButton() == cancel)
return; return;
MinecraftAccountPtr account = MSALoginDialog::newAccount( MinecraftAccountPtr account = MSALoginDialog::newAccount(this, box.clickedButton() == deviceCode);
this, tr("Please enter your Mojang account email and password to add your account."), box.clickedButton() == deviceCode);
if (account) { if (account) {
m_accounts->addAccount(account); m_accounts->addAccount(account);

View File

@ -10,4 +10,4 @@ Icon=org.prismlauncher.PrismLauncher
Categories=Game;ActionGame;AdventureGame;Simulation; Categories=Game;ActionGame;AdventureGame;Simulation;
Keywords=game;minecraft;mc; Keywords=game;minecraft;mc;
StartupWMClass=PrismLauncher StartupWMClass=PrismLauncher
MimeType=application/zip;application/x-modrinth-modpack+zip;x-scheme-handler/curseforge; MimeType=application/zip;application/x-modrinth-modpack+zip;x-scheme-handler/curseforge;x-scheme-handler/prismlauncher;

View File

@ -368,6 +368,10 @@ Section "@Launcher_DisplayName@"
WriteRegStr HKCU Software\Classes\curseforge "URL Protocol" "" WriteRegStr HKCU Software\Classes\curseforge "URL Protocol" ""
WriteRegStr HKCU Software\Classes\curseforge\shell\open\command "" '"$INSTDIR\@Launcher_APP_BINARY_NAME@.exe" "%1"' WriteRegStr HKCU Software\Classes\curseforge\shell\open\command "" '"$INSTDIR\@Launcher_APP_BINARY_NAME@.exe" "%1"'
; Write the URL Handler into registry for prismlauncher
WriteRegStr HKCU Software\Classes\prismlauncher "URL Protocol" ""
WriteRegStr HKCU Software\Classes\prismlauncher\shell\open\command "" '"$INSTDIR\@Launcher_APP_BINARY_NAME@.exe" "%1"'
; Write the uninstall keys for Windows ; Write the uninstall keys for Windows
${GetParameters} $R0 ${GetParameters} $R0
${GetOptions} $R0 "/NoUninstaller" $R1 ${GetOptions} $R0 "/NoUninstaller" $R1