Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ src/*.bak
CMakeLists.txt.user
edit
/CMakeFiles
.idea
.idea/*
!.idea/filetypes/
!.idea/filetypes/qt-translations.xml
/msbuild.log
/*std*.log
/*build

/src/version.aps
.idea/
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ find_package(mo2-esptk CONFIG REQUIRED)
find_package(mo2-dds-header CONFIG REQUIRED)
find_package(mo2-libbsarch CONFIG REQUIRED)

find_package(Qt6 REQUIRED COMPONENTS WebEngineWidgets WebSockets)
find_package(Qt6 REQUIRED COMPONENTS WebEngineWidgets WebSockets NetworkAuth)
find_package(Boost CONFIG REQUIRED COMPONENTS program_options thread interprocess signals2 uuid accumulators)
find_package(7zip CONFIG REQUIRED)
find_package(lz4 CONFIG REQUIRED)
Expand Down Expand Up @@ -41,7 +41,7 @@ target_link_libraries(organizer PRIVATE
usvfs::usvfs mo2::uibase mo2::archive mo2::libbsarch
mo2::bsatk mo2::esptk mo2::lootcli-header
Boost::program_options Boost::signals2 Boost::uuid Boost::accumulators
Qt6::WebEngineWidgets Qt6::WebSockets Version Dbghelp)
Qt6::WebEngineWidgets Qt6::WebSockets Qt6::NetworkAuth Version Dbghelp)

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/dlls.manifest.qt6"
DESTINATION ${_bin}/dlls
Expand Down
10 changes: 5 additions & 5 deletions src/apiuseraccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ APIUserAccount::APIUserAccount() : m_type(APIUserAccountTypes::None) {}

bool APIUserAccount::isValid() const
{
return !m_key.isEmpty();
return !m_accessToken.isEmpty();
}

const QString& APIUserAccount::apiKey() const
const QString& APIUserAccount::accessToken() const
{
return m_key;
return m_accessToken;
}

const QString& APIUserAccount::id() const
Expand All @@ -47,9 +47,9 @@ const APILimits& APIUserAccount::limits() const
return m_limits;
}

APIUserAccount& APIUserAccount::apiKey(const QString& key)
APIUserAccount& APIUserAccount::accessToken(const QString& token)
{
m_key = key;
m_accessToken = token;
return *this;
}

Expand Down
10 changes: 5 additions & 5 deletions src/apiuseraccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class APIUserAccount
bool isValid() const;

/**
* api key
* OAuth access token
*/
const QString& apiKey() const;
const QString& accessToken() const;

/**
* user id
Expand All @@ -90,9 +90,9 @@ class APIUserAccount
const APILimits& limits() const;

/**
* sets the api key
* sets the OAuth access token
*/
APIUserAccount& apiKey(const QString& key);
APIUserAccount& accessToken(const QString& token);

/**
* sets the user id
Expand Down Expand Up @@ -132,7 +132,7 @@ class APIUserAccount
bool exhausted() const;

private:
QString m_key, m_id, m_name;
QString m_accessToken, m_id, m_name;
APIUserAccountTypes m_type;
APILimits m_limits;
};
Expand Down
2 changes: 1 addition & 1 deletion src/createinstancedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Settings;
//
// pages can be disabled if they return true in skip(), which happens globally
// for some (IntroPage has a setting in the registry), depending on context
// (NexusPage is skipped if the API key already exists) or explicitly (when
// (NexusPage is skipped if the Nexus authorization already exists) or explicitly (when
// only some info about the instance is missing on startup, such as a game
// variant)
//
Expand Down
18 changes: 5 additions & 13 deletions src/createinstancedialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1095,18 +1095,11 @@
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="nexusManual">
<property name="text">
<string>Enter API Key Manually</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QListWidget" name="nexusLog"/>
</item>
Expand Down Expand Up @@ -1339,7 +1332,6 @@
<tabstop>overwrite</tabstop>
<tabstop>browseOverwrite</tabstop>
<tabstop>nexusConnect</tabstop>
<tabstop>nexusManual</tabstop>
<tabstop>nexusLog</tabstop>
<tabstop>review</tabstop>
<tabstop>creationLog</tabstop>
Expand Down
5 changes: 3 additions & 2 deletions src/createinstancedialogpages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void Page::next()

bool Page::action(CreateInstanceDialog::Actions a)
{
Q_UNUSED(a);
// no-op
return false;
}
Expand Down Expand Up @@ -1199,11 +1200,11 @@ bool PathsPage::checkPath(QString path, PlaceholderLabel& existsLabel,
NexusPage::NexusPage(CreateInstanceDialog& dlg) : Page(dlg), m_skip(false)
{
m_connectionUI.reset(new NexusConnectionUI(&m_dlg, dlg.settings(), ui->nexusConnect,
nullptr, ui->nexusManual, ui->nexusLog));
nullptr, ui->nexusLog));

// just check it once, or connecting and then going back and forth would skip
// the page, which would be unexpected
m_skip = GlobalSettings::hasNexusApiKey();
m_skip = GlobalSettings::hasNexusOAuthTokens();
}

NexusPage::~NexusPage() = default;
Expand Down
1 change: 1 addition & 0 deletions src/dlls.manifest.debug.qt6
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<file name="Qt6Cored.dll" />
<file name="Qt6Guid.dll" />
<file name="Qt6Networkd.dll" />
<file name="Qt6NetworkAuthd.dll" />
<file name="Qt6OpenGLd.dll" />
<file name="Qt6OpenGLWidgetsd.dll" />
<file name="Qt6Positioningd.dll" />
Expand Down
1 change: 1 addition & 0 deletions src/dlls.manifest.qt6
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<file name="Qt6Core.dll" />
<file name="Qt6Gui.dll" />
<file name="Qt6Network.dll" />
<file name="Qt6NetworkAuth.dll" />
<file name="Qt6OpenGL.dll" />
<file name="Qt6OpenGLWidgets.dll" />
<file name="Qt6Positioning.dll" />
Expand Down
6 changes: 3 additions & 3 deletions src/moapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ int MOApplication::run(MOMultiProcess& multiProcess)
tt.start("MOApplication::doOneRun() finishing");

// start an api check
QString apiKey;
if (GlobalSettings::nexusApiKey(apiKey)) {
m_nexus->getAccessManager()->apiCheck(apiKey);
NexusOAuthTokens tokens;
if (GlobalSettings::nexusOAuthTokens(tokens)) {
m_nexus->getAccessManager()->apiCheck(tokens);
}

// tutorials
Expand Down
12 changes: 6 additions & 6 deletions src/modlistviewactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ void ModListViewActions::checkModsForUpdates() const
QString());
NexusInterface::instance().requestTrackingInfo(m_receiver, QVariant(), QString());
} else {
QString apiKey;
if (GlobalSettings::nexusApiKey(apiKey)) {
NexusOAuthTokens tokens;
if (GlobalSettings::nexusOAuthTokens(tokens)) {
m_core.doAfterLogin([=]() {
checkModsForUpdates();
});
NexusInterface::instance().getAccessManager()->apiCheck(apiKey);
NexusInterface::instance().getAccessManager()->apiCheck(tokens);
} else {
log::warn("{}", tr("You are not currently authenticated with Nexus. Please do so "
"under Settings -> Nexus."));
Expand Down Expand Up @@ -310,12 +310,12 @@ void ModListViewActions::checkModsForUpdates(
if (NexusInterface::instance().getAccessManager()->validated()) {
ModInfo::manualUpdateCheck(m_receiver, IDs);
} else {
QString apiKey;
if (GlobalSettings::nexusApiKey(apiKey)) {
NexusOAuthTokens tokens;
if (GlobalSettings::nexusOAuthTokens(tokens)) {
m_core.doAfterLogin([=]() {
checkModsForUpdates(IDs);
});
NexusInterface::instance().getAccessManager()->apiCheck(apiKey);
NexusInterface::instance().getAccessManager()->apiCheck(tokens);
} else
log::warn("{}", tr("You are not currently authenticated with Nexus. Please do so "
"under Settings -> Nexus."));
Expand Down
16 changes: 15 additions & 1 deletion src/nexusinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,21 @@ void NexusInterface::nextRequest()
request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute,
QNetworkRequest::AlwaysNetwork);
request.setRawHeader("APIKEY", m_User.apiKey().toUtf8());
if (!m_AccessManager->ensureFreshToken()) {
log::error("nexus: unable to refresh OAuth token, request aborted");
info.m_Reply = nullptr;
return;
}

const auto currentTokens = m_AccessManager->tokens();
if (!currentTokens || currentTokens->accessToken.isEmpty()) {
log::error("nexus: no OAuth token available, request aborted");
info.m_Reply = nullptr;
return;
}

const auto bearer = QStringLiteral("Bearer %1").arg(currentTokens->accessToken);
request.setRawHeader("Authorization", bearer.toUtf8());
request.setHeader(QNetworkRequest::KnownHeaders::UserAgentHeader,
m_AccessManager->userAgent(info.m_SubModule));
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader,
Expand Down
Loading