mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-09 15:17:26 +08:00
[+] Automatically invalidate token on expiry
This commit is contained in:
@@ -45,6 +45,15 @@ export async function post(endpoint: string, params: any, init?: RequestInitWith
|
|||||||
...init
|
...init
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
console.error(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')
|
throw new Error('Network error')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user