Unauth users were unable to view collections

This commit is contained in:
Justin Edmund 2022-03-04 06:44:41 -08:00
parent ea24777eb7
commit 54d34fed12
2 changed files with 16 additions and 6 deletions

View file

@ -50,21 +50,26 @@ const ProfileRoute: React.FC = () => {
}, []) }, [])
const fetchProfile = useCallback(() => { const fetchProfile = useCallback(() => {
const filterParams = { const filters = {
params: { params: {
element: element, element: element,
raid: raidId, raid: raidId,
recency: recencyInSeconds recency: recencyInSeconds
}, }
}
const headers = {
headers: { headers: {
'Authorization': `Bearer ${cookies.account.access_token}` 'Authorization': `Bearer ${cookies.account.access_token}`
} }
} }
const params = (cookies.account) ? {...filters, ...headers} : filters
setLoading(true) setLoading(true)
if (username) if (username)
api.endpoints.users.getOne({ id: username as string, params: filterParams }) api.endpoints.users.getOne({ id: username as string, params: params })
.then(response => { .then(response => {
setUser({ setUser({
id: response.data.user.id, id: response.data.user.id,

View file

@ -43,20 +43,25 @@ const TeamsRoute: React.FC = () => {
}, []) }, [])
const fetchTeams = useCallback(() => { const fetchTeams = useCallback(() => {
const filterParams = { const filters = {
params: { params: {
element: element, element: element,
raid: raidId, raid: raidId,
recency: recencyInSeconds recency: recencyInSeconds
}, }
}
const headers = {
headers: { headers: {
'Authorization': `Bearer ${cookies.account?.access_token}` 'Authorization': `Bearer ${cookies.account?.access_token}`
} }
} }
const params = (cookies.account) ? {...filters, ...headers} : filters
setLoading(true) setLoading(true)
api.endpoints.parties.getAll(filterParams) api.endpoints.parties.getAll(params)
.then(response => { .then(response => {
const parties: Party[] = response.data const parties: Party[] = response.data
setParties(parties.map((p: any) => p.party).sort((a, b) => (a.created_at > b.created_at) ? -1 : 1)) setParties(parties.map((p: any) => p.party).sort((a, b) => (a.created_at > b.created_at) ? -1 : 1))