forked from platypush/platypush
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:
parent
0de56ad52e
commit
74ab884b7a
1 changed files with 19 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue