summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2025-07-29 19:42:45 +0800
committerErik Kundiman <erik@megapahit.org>2025-07-30 08:35:30 +0800
commitc40796a34472bfe51e7d9956cd5b9b74bd7739cf (patch)
tree60622d1288ab5a6a80538f269a99e3045309ba84
parent7cdce09bda9ff18bd02e22ddbe1b3fe95b204192 (diff)
Check Discord creds existence before getting token
as suggested by Andrey Kleshchev, anticipating external factors such as user moving settings from another PC.
-rw-r--r--indra/newview/llappviewer.cpp30
1 files changed, 20 insertions, 10 deletions
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);
+ });
+ }
}
}