Add back AuthlibInjectorMetadataStep
Apparently this was forgotten during the 9.0 merging.
This commit is contained in:
parent
fde597aa0a
commit
0e943b4bb1
@ -238,6 +238,8 @@ set(MINECRAFT_SOURCES
|
||||
minecraft/auth/AuthFlow.cpp
|
||||
minecraft/auth/AuthFlow.h
|
||||
|
||||
minecraft/auth/steps/AuthlibInjectorMetadataStep.cpp
|
||||
minecraft/auth/steps/AuthlibInjectorMetadataStep.h
|
||||
minecraft/auth/steps/EntitlementsStep.cpp
|
||||
minecraft/auth/steps/EntitlementsStep.h
|
||||
minecraft/auth/steps/GetSkinStep.cpp
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QNetworkRequest>
|
||||
|
||||
#include "minecraft/auth/AccountData.h"
|
||||
#include "minecraft/auth/steps/AuthlibInjectorMetadataStep.h"
|
||||
#include "minecraft/auth/steps/EntitlementsStep.h"
|
||||
#include "minecraft/auth/steps/GetSkinStep.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) {
|
||||
m_steps.append(makeShared<YggdrasilStep>(m_data, password));
|
||||
m_steps.append(makeShared<YggdrasilMinecraftProfileStep>(m_data));
|
||||
m_steps.append(makeShared<AuthlibInjectorMetadataStep>(m_data));
|
||||
m_steps.append(makeShared<GetSkinStep>(m_data));
|
||||
}
|
||||
changeState(AccountTaskState::STATE_CREATED);
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QNetworkRequest>
|
||||
|
||||
#include "minecraft/auth/AuthRequest.h"
|
||||
#include "minecraft/auth/Parsers.h"
|
||||
#include "Application.h"
|
||||
|
||||
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."));
|
||||
return;
|
||||
}
|
||||
QNetworkRequest request = QNetworkRequest(m_data->customAuthlibInjectorUrl);
|
||||
AuthRequest* requestor = new AuthRequest(this);
|
||||
connect(requestor, &AuthRequest::finished, this, &AuthlibInjectorMetadataStep::onRequestDone);
|
||||
requestor->get(request);
|
||||
|
||||
QUrl url{m_data->customAuthlibInjectorUrl};
|
||||
|
||||
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(QNetworkReply::NetworkError error,
|
||||
QByteArray data,
|
||||
QList<QNetworkReply::RawHeaderPair> headers)
|
||||
void AuthlibInjectorMetadataStep::onRequestDone()
|
||||
{
|
||||
auto requestor = qobject_cast<AuthRequest*>(QObject::sender());
|
||||
requestor->deleteLater();
|
||||
|
||||
if (error == QNetworkReply::NoError && data.size() > 0) {
|
||||
if (m_request->error() == QNetworkReply::NoError && m_response->size() > 0) {
|
||||
QJsonParseError jsonError;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(data, &jsonError);
|
||||
QJsonDocument doc = QJsonDocument::fromJson(*m_response, &jsonError);
|
||||
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."));
|
||||
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
|
||||
#include <QObject>
|
||||
|
||||
#include "QObjectPtr.h"
|
||||
#include "minecraft/auth/AuthStep.h"
|
||||
#include "net/NetJob.h"
|
||||
#include "net/Download.h"
|
||||
|
||||
class AuthlibInjectorMetadataStep : public AuthStep {
|
||||
Q_OBJECT
|
||||
@ -12,10 +13,14 @@ class AuthlibInjectorMetadataStep : public AuthStep {
|
||||
virtual ~AuthlibInjectorMetadataStep() noexcept;
|
||||
|
||||
void perform() override;
|
||||
void rehydrate() override;
|
||||
|
||||
QString describe() override;
|
||||
|
||||
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