perf: Re-login after csrf expires

This commit is contained in:
feng
2024-12-13 10:19:04 +08:00
committed by feng626
parent 8a048f692f
commit 7d89cf9f45

View File

@@ -89,10 +89,18 @@ function ifBadRequest({ response, error }) {
}
}
export function logout() {
window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${router.fullPath}`
}
export function flashErrorMsg({ response, error }) {
if (!response.config.disableFlashErrorMsg) {
const responseErrorMsg = getErrorResponseMsg(error)
const msg = responseErrorMsg || error.message
if (response.status === 403 && msg === 'CSRF Failed: CSRF token missing.') {
setTimeout(() => { logout() }, 1000)
}
message({
message: msg,
type: 'error',