aboutsummaryrefslogtreecommitdiff
path: root/launcher/net/Upload.cpp
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2023-03-09 15:10:40 +0100
committerGitHub <noreply@github.com>2023-03-09 15:10:40 +0100
commit1dd96898e1e6c68146424a3af66b2734a88fc23e (patch)
tree4941c84c291231d42e8a1caacab4dfe582be919e /launcher/net/Upload.cpp
parent3bd4ad7c93486e29c4dccc17d5d42719b452fd08 (diff)
parent59b15c5f08e00e2da0f77b9544881e93158320ed (diff)
downloadPrismLauncher-1dd96898e1e6c68146424a3af66b2734a88fc23e.tar.gz
PrismLauncher-1dd96898e1e6c68146424a3af66b2734a88fc23e.tar.bz2
PrismLauncher-1dd96898e1e6c68146424a3af66b2734a88fc23e.zip
Merge pull request #896 from TheKodeToad/modrinth-token
Diffstat (limited to 'launcher/net/Upload.cpp')
-rw-r--r--launcher/net/Upload.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/launcher/net/Upload.cpp b/launcher/net/Upload.cpp
index 79b6af8d..ccf43c2d 100644
--- a/launcher/net/Upload.cpp
+++ b/launcher/net/Upload.cpp
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -216,10 +217,16 @@ namespace Net {
}
request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8());
- if (APPLICATION->capabilities() & Application::SupportsFlame
- && request.url().host().contains("api.curseforge.com")) {
+ // TODO remove duplication
+ if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) {
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
+ } else if (request.url().host() == QUrl(BuildConfig.MODRINTH_PROD_URL).host() ||
+ request.url().host() == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) {
+ QString token = APPLICATION->getModrinthAPIToken();
+ if (!token.isNull())
+ request.setRawHeader("Authorization", token.toUtf8());
}
+
//TODO other types of post requests ?
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QNetworkReply* rep = m_network->post(request, m_post_data);