diff --git a/platypush/backend/http/webapp/src/utils/Api.vue b/platypush/backend/http/webapp/src/utils/Api.vue index 5118813d9..12305fcee 100644 --- a/platypush/backend/http/webapp/src/utils/Api.vue +++ b/platypush/backend/http/webapp/src/utils/Api.vue @@ -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,