From 54d34fed121f8c2e955a0de186d15b41827c828b Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 4 Mar 2022 06:44:41 -0800 Subject: [PATCH] Unauth users were unable to view collections --- pages/[username].tsx | 11 ++++++++--- pages/teams.tsx | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pages/[username].tsx b/pages/[username].tsx index 829109ec..8d16dd58 100644 --- a/pages/[username].tsx +++ b/pages/[username].tsx @@ -50,21 +50,26 @@ const ProfileRoute: React.FC = () => { }, []) const fetchProfile = useCallback(() => { - const filterParams = { + const filters = { params: { element: element, raid: raidId, recency: recencyInSeconds - }, + } + } + + const headers = { headers: { 'Authorization': `Bearer ${cookies.account.access_token}` } } + const params = (cookies.account) ? {...filters, ...headers} : filters + setLoading(true) if (username) - api.endpoints.users.getOne({ id: username as string, params: filterParams }) + api.endpoints.users.getOne({ id: username as string, params: params }) .then(response => { setUser({ id: response.data.user.id, diff --git a/pages/teams.tsx b/pages/teams.tsx index 91cc1c9c..e81e4cfb 100644 --- a/pages/teams.tsx +++ b/pages/teams.tsx @@ -43,20 +43,25 @@ const TeamsRoute: React.FC = () => { }, []) const fetchTeams = useCallback(() => { - const filterParams = { + const filters = { params: { element: element, raid: raidId, recency: recencyInSeconds - }, + } + } + + const headers = { headers: { 'Authorization': `Bearer ${cookies.account?.access_token}` } } + const params = (cookies.account) ? {...filters, ...headers} : filters + setLoading(true) - api.endpoints.parties.getAll(filterParams) + api.endpoints.parties.getAll(params) .then(response => { const parties: Party[] = response.data setParties(parties.map((p: any) => p.party).sort((a, b) => (a.created_at > b.created_at) ? -1 : 1))