Add back AuthlibInjectorMetadataStep
Apparently this was forgotten during the 9.0 merging.
This commit is contained in:
parent
dd3a788f7b
commit
7c6204b5f1
@ -238,6 +238,8 @@ set(MINECRAFT_SOURCES
|
|||||||
minecraft/auth/AuthFlow.cpp
|
minecraft/auth/AuthFlow.cpp
|
||||||
minecraft/auth/AuthFlow.h
|
minecraft/auth/AuthFlow.h
|
||||||
|
|
||||||
|
minecraft/auth/steps/AuthlibInjectorMetadataStep.cpp
|
||||||
|
minecraft/auth/steps/AuthlibInjectorMetadataStep.h
|
||||||
minecraft/auth/steps/EntitlementsStep.cpp
|
minecraft/auth/steps/EntitlementsStep.cpp
|
||||||
minecraft/auth/steps/EntitlementsStep.h
|
minecraft/auth/steps/EntitlementsStep.h
|
||||||
minecraft/auth/steps/GetSkinStep.cpp
|
minecraft/auth/steps/GetSkinStep.cpp
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
|
|
||||||
#include "minecraft/auth/AccountData.h"
|
#include "minecraft/auth/AccountData.h"
|
||||||
|
#include "minecraft/auth/steps/AuthlibInjectorMetadataStep.h"
|
||||||
#include "minecraft/auth/steps/EntitlementsStep.h"
|
#include "minecraft/auth/steps/EntitlementsStep.h"
|
||||||
#include "minecraft/auth/steps/GetSkinStep.h"
|
#include "minecraft/auth/steps/GetSkinStep.h"
|
||||||
#include "minecraft/auth/steps/LauncherLoginStep.h"
|
#include "minecraft/auth/steps/LauncherLoginStep.h"
|
||||||
@ -46,6 +47,7 @@ AuthFlow::AuthFlow(AccountData* data, Action action, const std::optional<QString
|
|||||||
} else if (data->type == AccountType::AuthlibInjector) {
|
} else if (data->type == AccountType::AuthlibInjector) {
|
||||||
m_steps.append(makeShared<YggdrasilStep>(m_data, password));
|
m_steps.append(makeShared<YggdrasilStep>(m_data, password));
|
||||||
m_steps.append(makeShared<YggdrasilMinecraftProfileStep>(m_data));
|
m_steps.append(makeShared<YggdrasilMinecraftProfileStep>(m_data));
|
||||||
|
m_steps.append(makeShared<AuthlibInjectorMetadataStep>(m_data));
|
||||||
m_steps.append(makeShared<GetSkinStep>(m_data));
|
m_steps.append(makeShared<GetSkinStep>(m_data));
|
||||||
}
|
}
|
||||||
changeState(AccountTaskState::STATE_CREATED);
|
changeState(AccountTaskState::STATE_CREATED);
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
|
#include "Application.h"
|
||||||
#include "minecraft/auth/AuthRequest.h"
|
|
||||||
#include "minecraft/auth/Parsers.h"
|
|
||||||
|
|
||||||
AuthlibInjectorMetadataStep::AuthlibInjectorMetadataStep(AccountData* data) : AuthStep(data) {}
|
AuthlibInjectorMetadataStep::AuthlibInjectorMetadataStep(AccountData* data) : AuthStep(data) {}
|
||||||
|
|
||||||
@ -21,29 +19,32 @@ void AuthlibInjectorMetadataStep::perform()
|
|||||||
emit finished(AccountTaskState::STATE_WORKING, tr("Account has no authlib-injector URL."));
|
emit finished(AccountTaskState::STATE_WORKING, tr("Account has no authlib-injector URL."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QNetworkRequest request = QNetworkRequest(m_data->customAuthlibInjectorUrl);
|
|
||||||
AuthRequest* requestor = new AuthRequest(this);
|
QUrl url{m_data->customAuthlibInjectorUrl};
|
||||||
connect(requestor, &AuthRequest::finished, this, &AuthlibInjectorMetadataStep::onRequestDone);
|
|
||||||
requestor->get(request);
|
m_response.reset(new QByteArray());
|
||||||
|
m_request = Net::Download::makeByteArray(url, m_response);
|
||||||
|
|
||||||
|
m_task.reset(new NetJob("AuthlibInjectorMetadataStep", APPLICATION->network()));
|
||||||
|
m_task->setAskRetry(false);
|
||||||
|
m_task->setAutoRetryLimit(0);
|
||||||
|
m_task->addNetAction(m_request);
|
||||||
|
|
||||||
|
connect(m_task.get(), &Task::finished, this, &AuthlibInjectorMetadataStep::onRequestDone);
|
||||||
|
|
||||||
|
m_task->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthlibInjectorMetadataStep::rehydrate() {}
|
void AuthlibInjectorMetadataStep::onRequestDone()
|
||||||
|
|
||||||
void AuthlibInjectorMetadataStep::onRequestDone(QNetworkReply::NetworkError error,
|
|
||||||
QByteArray data,
|
|
||||||
QList<QNetworkReply::RawHeaderPair> headers)
|
|
||||||
{
|
{
|
||||||
auto requestor = qobject_cast<AuthRequest*>(QObject::sender());
|
if (m_request->error() == QNetworkReply::NoError && m_response->size() > 0) {
|
||||||
requestor->deleteLater();
|
|
||||||
|
|
||||||
if (error == QNetworkReply::NoError && data.size() > 0) {
|
|
||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data, &jsonError);
|
QJsonDocument doc = QJsonDocument::fromJson(*m_response, &jsonError);
|
||||||
if (jsonError.error == QJsonParseError::NoError) {
|
if (jsonError.error == QJsonParseError::NoError) {
|
||||||
m_data->authlibInjectorMetadata = data.toBase64();
|
m_data->authlibInjectorMetadata = m_response->toBase64();
|
||||||
emit finished(AccountTaskState::STATE_WORKING, tr("Got authlib-injector metadata."));
|
emit finished(AccountTaskState::STATE_WORKING, tr("Got authlib-injector metadata."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit finished(AccountTaskState::STATE_WORKING, tr("Didn't get authlib-injector metadata, continuing anyway."));
|
emit finished(AccountTaskState::STATE_WORKING, tr("Couldn't get authlib-injector metadata, continuing anyway."));
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "QObjectPtr.h"
|
|
||||||
#include "minecraft/auth/AuthStep.h"
|
#include "minecraft/auth/AuthStep.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
#include "net/Download.h"
|
||||||
|
|
||||||
class AuthlibInjectorMetadataStep : public AuthStep {
|
class AuthlibInjectorMetadataStep : public AuthStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -12,10 +13,14 @@ class AuthlibInjectorMetadataStep : public AuthStep {
|
|||||||
virtual ~AuthlibInjectorMetadataStep() noexcept;
|
virtual ~AuthlibInjectorMetadataStep() noexcept;
|
||||||
|
|
||||||
void perform() override;
|
void perform() override;
|
||||||
void rehydrate() override;
|
|
||||||
|
|
||||||
QString describe() override;
|
QString describe() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onRequestDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
void onRequestDone();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<QByteArray> m_response;
|
||||||
|
Net::Download::Ptr m_request;
|
||||||
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user