Proper redirects upon `/execute` failure.

If a call to `/execute` fails with a 401 or 412 status, then redirect
the user to `/register` or `/login`.
This commit is contained in:
Fabio Manganiello 2023-05-10 02:24:50 +02:00
parent 0de56ad52e
commit 74ab884b7a
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
1 changed files with 19 additions and 0 deletions

View File

@ -36,6 +36,25 @@ export default {
}
})
.catch((error) => {
// No users present -> redirect to the registration page
if (
error?.response?.data?.code === 412 &&
window.location.href.indexOf('/register') < 0
) {
window.location.href = '/register?redirect=' + window.location.href
return
}
// Unauthorized -> redirect to the login page
if (
error?.response?.data?.code === 401 &&
window.location.href.indexOf('/login') < 0
) {
window.location.href = '/login?redirect=' + window.location.href
return
}
console.log(error)
if (showError)
this.notify({
text: error,