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 untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -36,6 +36,25 @@ export default {
} }
}) })
.catch((error) => { .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) if (showError)
this.notify({ this.notify({
text: error, text: error,