From 73c146b9ac9d5dada1de12b406baae1d698e8240 Mon Sep 17 00:00:00 2001 From: jessop Date: Tue, 27 Oct 2020 21:29:45 -0400 Subject: [PATCH] send auth token with status call --- static/app-strings.json | 5 +---- web/effects/use-degraded-performance.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/static/app-strings.json b/static/app-strings.json index 13e86fb46..05cc25e6f 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -1329,7 +1329,6 @@ "Replying as": "Replying as", "No uploads": "No uploads", "uploads": "uploads", - "Community": "Community", "Staked LBRY Credits": "Staked LBRY Credits", "1 comment": "1 comment", "%total_comments% comments": "%total_comments% comments", @@ -1349,8 +1348,6 @@ "Credit Details": "Credit Details", "LBRY Credits": "LBRY Credits", "Mark all as read": "Mark all as read", - "Log in to %SITE_NAME% to earn rewards From Inviting Your Friends": "Log in to %SITE_NAME% to earn rewards From Inviting Your Friends", - "Confirming...": "Confirming...", "Pinned by @%channel%": "Pinned by @%channel%", "Pinned by creator": "Pinned by creator", "Claim Your %reward_amount% Credit Invite Reward": "Claim Your %reward_amount% Credit Invite Reward", @@ -1383,7 +1380,6 @@ "Email Verified": "Email Verified", "Inviter Bonus": "Inviter Bonus", "Daily Watch Reward": "Daily Watch Reward", - "Mark all as read": "Mark all as read", "Odyseenaut": "Odyseenaut", "Watch 10 things, like 5 things, and leave a comment on odysee.com.": "Watch 10 things, like 5 things, and leave a comment on odysee.com.", "Earn an upgrade reward with each LBRY update. Patches will not trigger a new reward.": "Earn an upgrade reward with each LBRY update. Patches will not trigger a new reward.", @@ -1460,5 +1456,6 @@ "Unpin": "Unpin", "LBRY leveled up": "LBRY leveled up", "This link leads to an external website.": "This link leads to an external website.", + "Hold on, we are setting up your account": "Hold on, we are setting up your account", "--end--": "--end--" } diff --git a/web/effects/use-degraded-performance.js b/web/effects/use-degraded-performance.js index ea1684dd3..e75d4f2f2 100644 --- a/web/effects/use-degraded-performance.js +++ b/web/effects/use-degraded-performance.js @@ -1,5 +1,7 @@ import { SDK_API_PATH } from 'ui'; import { useEffect } from 'react'; +import { getAuthToken } from 'util/saved-passwords'; +import { X_LBRY_AUTH_TOKEN } from 'constants/token'; import fetchWithTimeout from 'util/fetch'; @@ -9,13 +11,23 @@ export const STATUS_DEGRADED = 'degraded'; export const STATUS_FAILING = 'failing'; export const STATUS_DOWN = 'down'; +const getParams = () => { + const headers = {}; + const token = getAuthToken(); + if (token) { + headers[X_LBRY_AUTH_TOKEN] = token; + } + const params = { headers }; + return params; +}; + export function useDegradedPerformance(onDegradedPerformanceCallback) { useEffect(() => { // The status endpoint is the only endpoint at "v2" currently // This should be moved into the config once more endpoints are using it const STATUS_ENDPOINT = `${SDK_API_PATH}/status`.replace('v1', 'v2'); - fetchWithTimeout(STATUS_TIMEOUT_LIMIT, fetch(STATUS_ENDPOINT)) + fetchWithTimeout(STATUS_TIMEOUT_LIMIT, fetch(STATUS_ENDPOINT, getParams())) .then(response => response.json()) .then(status => { if (status.general_state !== STATUS_OK) {