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")
{
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));

View File

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

View File

@ -115,7 +115,7 @@ struct AccountData {
QString lastError() const;
QString customUrl const;
QString customUrl;
AccountType type = AccountType::MSA;
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) {
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(failed(QString)), SLOT(authFailed(QString)));
connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); });

View File

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

View File

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

View File

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

View File

@ -24,7 +24,7 @@ void CustomProfileStep::perform() {
// 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);
AuthRequest *request = new AuthRequest(this);
connect(request, &AuthRequest::finished, this, &CustomProfileStep::onRequestDone);

View File

@ -4,7 +4,7 @@
#include "minecraft/auth/Parsers.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);
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() {
emit finished(AccountTaskState::STATE_WORKING, tr("Logged in with Custom"));
}

View File

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

View File

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