From c40796a34472bfe51e7d9956cd5b9b74bd7739cf Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 29 Jul 2025 19:42:45 +0800 Subject: Check Discord creds existence before getting token as suggested by Andrey Kleshchev, anticipating external factors such as user moving settings from another PC. --- indra/newview/llappviewer.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'indra') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index fee2a742f5..16e2027af1 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -5933,10 +5933,14 @@ void LLAppViewer::initDiscordSocial() }); if (gSavedSettings.getBOOL("EnableDiscord")) { - gDiscordClient->UpdateToken(discordpp::AuthorizationTokenType::Bearer, gSecAPIHandler->loadCredential("Discord")->getAuthenticator()["token"].asString(), [](discordpp::ClientResult result) { - if (result.Successful()) - gDiscordClient->Connect(); - }); + auto credential = gSecAPIHandler->loadCredential("Discord"); + if (credential.notNull()) + { + gDiscordClient->UpdateToken(discordpp::AuthorizationTokenType::Bearer, credential->getAuthenticator()["token"].asString(), [](discordpp::ClientResult result) { + if (result.Successful()) + gDiscordClient->Connect(); + }); + } } } @@ -5971,12 +5975,18 @@ void LLAppViewer::handleDiscordSocial(const LLSD& value) } else { - gDiscordClient->RevokeToken(APPLICATION_ID, gSecAPIHandler->loadCredential("Discord")->getAuthenticator()["token"].asString(), [](discordpp::ClientResult result) { - if (result.Successful()) - gDiscordClient->Disconnect(); - auto cred = new LLCredential("Discord"); - gSecAPIHandler->deleteCredential(cred); - }); + auto credential = gSecAPIHandler->loadCredential("Discord"); + if (credential.notNull()) + { + gDiscordClient->RevokeToken(APPLICATION_ID, credential->getAuthenticator()["token"].asString(), [](discordpp::ClientResult result) { + if (result.Successful()) + { + gDiscordClient->Disconnect(); + } + auto cred = new LLCredential("Discord"); + gSecAPIHandler->deleteCredential(cred); + }); + } } } -- cgit v1.2.3