mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-09-06 12:25:52 +00:00
UltimMC: Fix ely.by auth
This commit is contained in:
@@ -233,6 +233,8 @@ set(MINECRAFT_SOURCES
|
||||
minecraft/auth/flows/MSA.h
|
||||
minecraft/auth/flows/Local.cpp
|
||||
minecraft/auth/flows/Local.h
|
||||
minecraft/auth/flows/Elyby.cpp
|
||||
minecraft/auth/flows/Elyby.h
|
||||
|
||||
minecraft/auth/steps/EntitlementsStep.cpp
|
||||
minecraft/auth/steps/EntitlementsStep.h
|
||||
|
@@ -388,7 +388,7 @@ QJsonObject AccountData::saveState() const {
|
||||
}
|
||||
|
||||
QString AccountData::userName() const {
|
||||
if(type != AccountType::Mojang) {
|
||||
if(type != AccountType::Mojang && type != AccountType::Elyby) {
|
||||
return QString();
|
||||
}
|
||||
return yggdrasilToken.extra["userName"].toString();
|
||||
@@ -399,14 +399,14 @@ QString AccountData::accessToken() const {
|
||||
}
|
||||
|
||||
QString AccountData::clientToken() const {
|
||||
if(type != AccountType::Mojang) {
|
||||
if(type != AccountType::Mojang && type != AccountType::Elyby) {
|
||||
return QString();
|
||||
}
|
||||
return yggdrasilToken.extra["clientToken"].toString();
|
||||
}
|
||||
|
||||
void AccountData::setClientToken(QString clientToken) {
|
||||
if(type != AccountType::Mojang) {
|
||||
if(type != AccountType::Mojang && type != AccountType::Elyby) {
|
||||
return;
|
||||
}
|
||||
yggdrasilToken.extra["clientToken"] = clientToken;
|
||||
@@ -420,7 +420,7 @@ void AccountData::generateClientTokenIfMissing() {
|
||||
}
|
||||
|
||||
void AccountData::invalidateClientToken() {
|
||||
if(type != AccountType::Mojang) {
|
||||
if(type != AccountType::Mojang && type != AccountType::Elyby) {
|
||||
return;
|
||||
}
|
||||
yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{-}]"));
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include "flows/MSA.h"
|
||||
#include "flows/Mojang.h"
|
||||
#include "flows/Local.h"
|
||||
#include "flows/Elyby.h"
|
||||
|
||||
MinecraftAccount::MinecraftAccount(QObject* parent) : QObject(parent) {
|
||||
data.internalId = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
||||
@@ -95,7 +96,6 @@ MinecraftAccountPtr MinecraftAccount::createLocal(const QString &username)
|
||||
account->data.yggdrasilToken.extra["userName"] = username;
|
||||
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
||||
account->data.minecraftProfile.id = uuidFromUsername(username).toString().remove(QRegExp("[{}-]"));
|
||||
account->data.minecraftProfile.id = account->data.internalId;
|
||||
account->data.minecraftProfile.name = username;
|
||||
account->data.minecraftProfile.validity = Katabasis::Validity::Certain;
|
||||
account->data.minecraftEntitlement.ownsMinecraft = true;
|
||||
@@ -109,13 +109,11 @@ MinecraftAccountPtr MinecraftAccount::createElyby(const QString &username)
|
||||
account->data.type = AccountType::Elyby;
|
||||
account->data.yggdrasilToken.extra["userName"] = username;
|
||||
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
||||
account->data.minecraftProfile.id = account->data.internalId;
|
||||
account->data.minecraftProfile.id = uuidFromUsername(username).toString().remove(QRegExp("[{}-]"));
|
||||
account->data.minecraftProfile.name = username;
|
||||
account->data.minecraftProfile.validity = Katabasis::Validity::Certain;
|
||||
account->data.validity_ = Katabasis::Validity::Certain;
|
||||
account->data.minecraftEntitlement.ownsMinecraft = true;
|
||||
account->data.minecraftEntitlement.canPlayMinecraft = true;
|
||||
account->data.minecraftEntitlement.validity = Katabasis::Validity::Certain;
|
||||
return account;
|
||||
}
|
||||
|
||||
@@ -180,6 +178,16 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::loginLocal() {
|
||||
return m_currentTask;
|
||||
}
|
||||
|
||||
shared_qobject_ptr<AccountTask> MinecraftAccount::loginElyby(QString password) {
|
||||
Q_ASSERT(m_currentTask.get() == nullptr);
|
||||
|
||||
m_currentTask.reset(new ElybyLogin(&data, password));
|
||||
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
||||
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
||||
emit activityChanged(true);
|
||||
return m_currentTask;
|
||||
}
|
||||
|
||||
shared_qobject_ptr<AccountTask> MinecraftAccount::refresh() {
|
||||
if(m_currentTask) {
|
||||
return m_currentTask;
|
||||
@@ -194,6 +202,9 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::refresh() {
|
||||
else if (data.type == AccountType::Local) {
|
||||
m_currentTask.reset(new LocalRefresh(&data));
|
||||
}
|
||||
else if (data.type == AccountType::Elyby) {
|
||||
m_currentTask.reset(new ElybyRefresh(&data));
|
||||
}
|
||||
|
||||
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
||||
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
||||
|
@@ -98,6 +98,8 @@ public: /* manipulation */
|
||||
|
||||
shared_qobject_ptr<AccountTask> loginLocal();
|
||||
|
||||
shared_qobject_ptr<AccountTask> loginElyby(QString password);
|
||||
|
||||
shared_qobject_ptr<AccountTask> refresh();
|
||||
|
||||
shared_qobject_ptr<AccountTask> currentTask();
|
||||
|
21
launcher/minecraft/auth/flows/Elyby.cpp
Normal file
21
launcher/minecraft/auth/flows/Elyby.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "Elyby.h"
|
||||
|
||||
#include "minecraft/auth/steps/YggdrasilStep.h"
|
||||
#include "minecraft/auth/steps/GetSkinStep.h"
|
||||
|
||||
ElybyRefresh::ElybyRefresh(
|
||||
AccountData *data,
|
||||
QObject *parent
|
||||
) : AuthFlow(data, parent) {
|
||||
m_steps.append(new YggdrasilStep(m_data, QString()));
|
||||
m_steps.append(new GetSkinStep(m_data));
|
||||
}
|
||||
|
||||
ElybyLogin::ElybyLogin(
|
||||
AccountData *data,
|
||||
QString password,
|
||||
QObject *parent
|
||||
): AuthFlow(data, parent), m_password(password) {
|
||||
m_steps.append(new YggdrasilStep(m_data, m_password));
|
||||
m_steps.append(new GetSkinStep(m_data));
|
||||
}
|
26
launcher/minecraft/auth/flows/Elyby.h
Normal file
26
launcher/minecraft/auth/flows/Elyby.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "AuthFlow.h"
|
||||
|
||||
class ElybyRefresh : public AuthFlow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ElybyRefresh(
|
||||
AccountData *data,
|
||||
QObject *parent = 0
|
||||
);
|
||||
};
|
||||
|
||||
class ElybyLogin : public AuthFlow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ElybyLogin(
|
||||
AccountData *data,
|
||||
QString password,
|
||||
QObject *parent = 0
|
||||
);
|
||||
|
||||
private:
|
||||
QString m_password;
|
||||
};
|
@@ -27,18 +27,6 @@ LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::LoginDia
|
||||
ui->progressBar->setVisible(false);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
for(auto provider: AuthProviders::getAll()) {
|
||||
auto providerId = provider->id();
|
||||
// Exclude Microsoft and Local accounts from here...
|
||||
if (providerId != "MSA" && providerId != "local") {
|
||||
QRadioButton *button = new QRadioButton(provider->displayName());
|
||||
m_radioButtons[providerId] = button;
|
||||
ui->radioLayout->addWidget(button);
|
||||
}
|
||||
}
|
||||
m_radioButtons["elyby"]->setChecked(true);
|
||||
adjustSize();
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
}
|
||||
@@ -54,16 +42,11 @@ void LoginDialog::accept()
|
||||
setUserInputsEnabled(false);
|
||||
ui->progressBar->setVisible(true);
|
||||
|
||||
m_account = MinecraftAccount::createFromUsername(ui->userTextBox->text());
|
||||
for(auto providerId: m_radioButtons.keys()){
|
||||
if(m_radioButtons[providerId]->isChecked()) {
|
||||
m_account->setProvider(AuthProviders::lookup(providerId));
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_account = MinecraftAccount::createElyby(ui->userTextBox->text());
|
||||
m_account->setProvider(AuthProviders::lookup("elyby"));
|
||||
|
||||
// Setup the login task and start it
|
||||
m_loginTask = m_account->login(ui->passTextBox->text());
|
||||
m_loginTask = m_account->loginElyby(ui->passTextBox->text());
|
||||
connect(m_loginTask.get(), &Task::failed, this, &LoginDialog::onTaskFailed);
|
||||
connect(m_loginTask.get(), &Task::succeeded, this, &LoginDialog::onTaskSucceeded);
|
||||
connect(m_loginTask.get(), &Task::status, this, &LoginDialog::onTaskStatus);
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QDialog>
|
||||
#include <QtWidgets/QRadioButton>
|
||||
#include <QtCore/QEventLoop>
|
||||
|
||||
#include "minecraft/auth/MinecraftAccount.h"
|
||||
@@ -56,6 +55,5 @@ slots:
|
||||
private:
|
||||
Ui::LoginDialog *ui;
|
||||
MinecraftAccountPtr m_account;
|
||||
QMap<QString, QRadioButton*> m_radioButtons;
|
||||
Task::Ptr m_loginTask;
|
||||
};
|
||||
|
@@ -60,9 +60,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="radioLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
|
@@ -47,7 +47,7 @@ AccountListPage::AccountListPage(QWidget *parent)
|
||||
ui->listView->setEmptyString(tr(
|
||||
"Welcome!\n"
|
||||
"If you're new here, you can click the \"Add Local\" button to add your local account.\n"
|
||||
"Or click the \"Add Premium\" button to add your Ely.by or Mojang account."
|
||||
"Or click the \"Add Ely.by\" button to add your Ely.by account."
|
||||
));
|
||||
ui->listView->setEmptyMode(VersionListView::String);
|
||||
ui->listView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
@@ -161,7 +161,7 @@ void AccountListPage::on_actionAddMicrosoft_triggered()
|
||||
}
|
||||
MinecraftAccountPtr account = MSALoginDialog::newAccount(
|
||||
this,
|
||||
tr("Please enter your account email and password to add your account.")
|
||||
tr("Please enter your Mojang account email and password to add your account.")
|
||||
);
|
||||
|
||||
if (account)
|
||||
@@ -227,7 +227,7 @@ void AccountListPage::updateButtonStates()
|
||||
ui->actionSetDefault->setEnabled(accountIsReady);
|
||||
ui->actionUploadSkin->setEnabled(accountIsReady && accountIsOnline);
|
||||
ui->actionDeleteSkin->setEnabled(accountIsReady && accountIsOnline);
|
||||
ui->actionRefresh->setEnabled(accountIsReady && accountIsOnline);
|
||||
ui->actionRefresh->setEnabled(accountIsReady);
|
||||
|
||||
if(m_accounts->defaultAccount().get() == nullptr) {
|
||||
ui->actionNoDefault->setEnabled(false);
|
||||
|
@@ -53,8 +53,8 @@
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionAddLocal"/>
|
||||
<addaction name="actionAddMicrosoft"/>
|
||||
<addaction name="actionAddMojang"/>
|
||||
<addaction name="actionAddMicrosoft"/>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="actionRemove"/>
|
||||
<addaction name="actionSetDefault"/>
|
||||
@@ -70,7 +70,7 @@
|
||||
</action>
|
||||
<action name="actionAddMojang">
|
||||
<property name="text">
|
||||
<string>Add Premium</string>
|
||||
<string>Add Ely.by</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemove">
|
||||
|
Reference in New Issue
Block a user