Skip to content

Commit

Permalink
feat: api auth crash issue
Browse files Browse the repository at this point in the history
  • Loading branch information
BRAVO68WEB committed Jan 3, 2024
1 parent 3f67774 commit 4c801a7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/web/src/pages/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function Player() {
"Authorization": "Bearer " + token,
}
}).then(res => {
if(!Array.isArray(res.data)) return window.location.href = '/login'
if(res.data.message === 'Invalid token') return window.location.href = '/login';
setMachines(res.data);
})
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/pages/leaderboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function Leaderboard() {
axios
.request(config)
.then((response) => {
if(!Array.isArray(response.data)) return window.location.href = '/login'
setLeaderboard(response.data);
})
.catch(() => {
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/pages/whoami.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function WhoAmI() {
"Authorization": "Bearer " + token,
}
}).then(res => {
if(res.data.error) return window.location.href = '/login'

if(res.data.message === 'Invalid token') return window.location.href = '/login';
setUserWhoami(res.data);
})
Expand All @@ -27,6 +29,8 @@ function WhoAmI() {
"Authorization": "Bearer " + token,
}
}).then(res => {
if(res.data.error) return window.location.href = '/login'

if(res.data.message === 'Invalid token') return window.location.href = '/login';
setTeamWhoami(res.data);
})
Expand All @@ -36,6 +40,7 @@ function WhoAmI() {
"Authorization": "Bearer " + token,
}
}).then(res => {
if(res.data.error) return window.location.href = '/login'
if(res.data.message === 'Invalid token') return window.location.href = '/login';
setTeamStats(res.data);
})
Expand Down

0 comments on commit 4c801a7

Please sign in to comment.