mirror of https://github.com/hykilpikonna/AquaDX
[F] Fix token invalidation
parent
279bcbfeab
commit
c0437e55eb
|
@ -64,14 +64,6 @@ export async function post(endpoint: string, params: any, init?: RequestInitWith
|
|||
}).catch(e => {
|
||||
console.error(e)
|
||||
|
||||
// If 400 invalid token is caught, should invalidate the token and redirect to signin
|
||||
if (e.message === 'Invalid token') {
|
||||
// Invalidate token
|
||||
localStorage.removeItem('token')
|
||||
// Redirect to signin
|
||||
window.location.href = '/'
|
||||
}
|
||||
|
||||
throw new Error('Network error')
|
||||
})
|
||||
|
||||
|
@ -79,6 +71,12 @@ export async function post(endpoint: string, params: any, init?: RequestInitWith
|
|||
const text = await res.text()
|
||||
console.error(`${res.status}: ${text}`)
|
||||
|
||||
// If 400 invalid token is caught, should invalidate the token and redirect to signin
|
||||
if (text === 'Invalid token') {
|
||||
localStorage.removeItem('token')
|
||||
window.location.href = '/'
|
||||
}
|
||||
|
||||
// Try to parse as json
|
||||
let json
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue