From 474d67f5913d1dfbcda9a5c6c5ca02272fdbc9ab Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 31 Aug 2021 09:02:43 -0700 Subject: [PATCH] Standalone: fallback to limited featureset when authenticated fetch is enabled --- app/soapbox/actions/external_auth.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/soapbox/actions/external_auth.js b/app/soapbox/actions/external_auth.js index da680c488..194b27cb1 100644 --- a/app/soapbox/actions/external_auth.js +++ b/app/soapbox/actions/external_auth.js @@ -13,12 +13,21 @@ import { authLoggedIn, verifyCredentials, switchAccount } from 'soapbox/actions/ import { parseBaseURL } from 'soapbox/utils/auth'; import { getFeatures } from 'soapbox/utils/features'; import sourceCode from 'soapbox/utils/code'; -import { fromJS } from 'immutable'; +import { Map as ImmutableMap, fromJS } from 'immutable'; const fetchExternalInstance = baseURL => { return baseClient(null, baseURL) .get('/api/v1/instance') - .then(({ data: instance }) => fromJS(instance)); + .then(({ data: instance }) => fromJS(instance)) + .catch(error => { + if (error.response.status === 401) { + // Authenticated fetch is enabled. + // Continue with a limited featureset. + return ImmutableMap({ version: '0.0.0' }); + } else { + throw error; + } + }); }; export function createAppAndRedirect(host) {