Fix the various different bugs i initially created

This commit is contained in:
0xf8 2023-06-20 15:08:02 -04:00
parent daa73a756a
commit 8e6c20dc99
Signed by: 0xf8
GPG Key ID: 446580D758689584
11 changed files with 28 additions and 19 deletions

View File

@ -1035,7 +1035,7 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
} }
else if (session->user_type == "custom") else if (session->user_type == "custom")
{ {
process->appendStep(makeShared<InjectAuthlib>(pptr, &m_injector, session.url)); process->appendStep(makeShared<InjectAuthlib>(pptr, &m_injector, session->url));
} }
process->appendStep(makeShared<Update>(pptr, Net::Mode::Online)); process->appendStep(makeShared<Update>(pptr, Net::Mode::Online));

View File

@ -355,7 +355,7 @@ bool AccountData::resumeStateFromV3(QJsonObject data) {
} else if (typeS == "Elyby") { } else if (typeS == "Elyby") {
type = AccountType::Elyby; type = AccountType::Elyby;
} else if (typeS == "Custom") { } else if (typeS == "Custom") {
type = AccountType::Custom type = AccountType::Custom;
} else { } else {
qWarning() << "Failed to parse account data: type is not recognized."; qWarning() << "Failed to parse account data: type is not recognized.";
return false; return false;

View File

@ -115,7 +115,7 @@ struct AccountData {
QString lastError() const; QString lastError() const;
QString customUrl const; QString customUrl;
AccountType type = AccountType::MSA; AccountType type = AccountType::MSA;
bool legacy = false; bool legacy = false;

View File

@ -200,7 +200,7 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::loginElyby(QString password) {
shared_qobject_ptr<AccountTask> MinecraftAccount::loginCustom(QString password, QString url) { shared_qobject_ptr<AccountTask> MinecraftAccount::loginCustom(QString password, QString url) {
Q_ASSERT(m_currentTask.get() == nullptr); Q_ASSERT(m_currentTask.get() == nullptr);
m_currentTask.reset(new customLogin(&data, password, url)); m_currentTask.reset(new CustomLogin(&data, password, url));
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded())); connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString))); connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); }); connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); });

View File

@ -150,8 +150,8 @@ public: /* queries */
return data.profileName(); return data.profileName();
} }
qString customUrl() const { QString customUrl() const {
return data.customUrl(); return data.customUrl;
} }
bool isActive() const; bool isActive() const;
@ -209,7 +209,7 @@ public: /* queries */
return "elyby"; return "elyby";
} }
break; break;
case AccountType::Custom { case AccountType::Custom: {
return "custom"; return "custom";
} }
break; break;

View File

@ -4,7 +4,7 @@
#include "minecraft/auth/steps/CustomProfileStep.h" #include "minecraft/auth/steps/CustomProfileStep.h"
#include "minecraft/auth/steps/GetSkinStep.h" #include "minecraft/auth/steps/GetSkinStep.h"
customRefresh::customRefresh( CustomRefresh::CustomRefresh(
AccountData *data, AccountData *data,
QObject *parent QObject *parent
) : AuthFlow(data, parent) { ) : AuthFlow(data, parent) {
@ -13,13 +13,15 @@ customRefresh::customRefresh(
m_steps.append(makeShared<GetSkinStep>(m_data)); m_steps.append(makeShared<GetSkinStep>(m_data));
} }
customLogin::customLogin( CustomLogin::CustomLogin(
AccountData *data, AccountData *data,
QString password, QString password,
QString url, QString url,
QObject *parent QObject *parent
): AuthFlow(data, parent), m_password(password), m_url(url) { ): AuthFlow(data, parent), m_password(password) {
m_steps.append(makeShared<CustomStep>(m_data, m_password, m_url)); auto step = makeShared<CustomStep>(m_data, m_password);
step.get()->setUrl(url);
m_steps.append(step);
m_steps.append(makeShared<CustomProfileStep>(m_data)); m_steps.append(makeShared<CustomProfileStep>(m_data));
m_steps.append(makeShared<GetSkinStep>(m_data)); m_steps.append(makeShared<GetSkinStep>(m_data));
} }

View File

@ -1,21 +1,21 @@
#pragma once #pragma once
#include "AuthFlow.h" #include "AuthFlow.h"
class customRefresh : public AuthFlow class CustomRefresh : public AuthFlow
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit customRefresh( explicit CustomRefresh(
AccountData *data, AccountData *data,
QObject *parent = 0 QObject *parent = 0
); );
}; };
class customLogin : public AuthFlow class CustomLogin : public AuthFlow
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit customLogin( explicit CustomLogin(
AccountData *data, AccountData *data,
QString password, QString password,
QString url, QString url,

View File

@ -24,7 +24,7 @@ void CustomProfileStep::perform() {
// m_data-> // m_data->
QUrl url = QUrl(m_data.customUrl + "/session/profile/" + m_data->minecraftProfile.id); QUrl url = QUrl(m_data->customUrl + "/session/profile/" + m_data->minecraftProfile.id);
QNetworkRequest req = QNetworkRequest(url); QNetworkRequest req = QNetworkRequest(url);
AuthRequest *request = new AuthRequest(this); AuthRequest *request = new AuthRequest(this);
connect(request, &AuthRequest::finished, this, &CustomProfileStep::onRequestDone); connect(request, &AuthRequest::finished, this, &CustomProfileStep::onRequestDone);

View File

@ -4,7 +4,7 @@
#include "minecraft/auth/Parsers.h" #include "minecraft/auth/Parsers.h"
#include "minecraft/auth/Yggdrasil.h" #include "minecraft/auth/Yggdrasil.h"
CustomStep::CustomStep(AccountData* data, QString password, QString url) : AuthStep(data), m_password(password), m_url(url) { CustomStep::CustomStep(AccountData* data, QString password) : AuthStep(data), m_password(password) {
m_yggdrasil = new Yggdrasil(m_data, this); m_yggdrasil = new Yggdrasil(m_data, this);
connect(m_yggdrasil, &Task::failed, this, &CustomStep::onAuthFailed); connect(m_yggdrasil, &Task::failed, this, &CustomStep::onAuthFailed);
@ -31,6 +31,10 @@ void CustomStep::perform() {
} }
} }
void CustomStep::setUrl(QString url) {
this->m_url = url;
}
void CustomStep::onAuthSucceeded() { void CustomStep::onAuthSucceeded() {
emit finished(AccountTaskState::STATE_WORKING, tr("Logged in with Custom")); emit finished(AccountTaskState::STATE_WORKING, tr("Logged in with Custom"));
} }

View File

@ -10,7 +10,7 @@ class CustomStep : public AuthStep {
Q_OBJECT Q_OBJECT
public: public:
explicit CustomStep(AccountData *data, QString password, QString url); explicit CustomStep(AccountData *data, QString password);
virtual ~CustomStep() noexcept; virtual ~CustomStep() noexcept;
void perform() override; void perform() override;
@ -18,6 +18,8 @@ public:
QString describe() override; QString describe() override;
void setUrl(QString url);
private slots: private slots:
void onAuthSucceeded(); void onAuthSucceeded();
void onAuthFailed(); void onAuthFailed();
@ -25,4 +27,5 @@ private slots:
private: private:
Yggdrasil *m_yggdrasil = nullptr; Yggdrasil *m_yggdrasil = nullptr;
QString m_password; QString m_password;
QString m_url;
}; };

View File

@ -40,7 +40,7 @@ class InjectAuthlib : public LaunchStep
{ {
Q_OBJECT Q_OBJECT
public: public:
InjectAuthlib(LaunchTask *parent, AuthlibInjectorPtr *injector); InjectAuthlib(LaunchTask *parent, AuthlibInjectorPtr *injector, QString url);
virtual ~InjectAuthlib(){}; virtual ~InjectAuthlib(){};
void executeTask() override; void executeTask() override;