From e07df08822acedc4666a091d7feebb37a5272e6f Mon Sep 17 00:00:00 2001 From: groegert Date: Sun, 26 Dec 2021 12:00:08 +0100 Subject: [PATCH] eleminate permanent spinner on login --- src/pages/Login.vue | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/pages/Login.vue b/src/pages/Login.vue index cf8eeea..fd5469f 100644 --- a/src/pages/Login.vue +++ b/src/pages/Login.vue @@ -121,11 +121,24 @@ export default defineComponent({ if (quasar.platform.is.capacitor) await sessionStore.updateSession(14 * 24 * 60 * 60, mainStore.currentSession.token); // Redirect user to previous page, if any. - const redirect = - router.currentRoute.value.redirectedFrom || 'redirect' in router.currentRoute.value.query - ? { path: router.currentRoute.value.query.redirect as string } - : mainRoute; - + // there are different redirects possible: + // 1. when explicitely entered + // a) http://localhost:8080/ -> should be redirected to mainRoute + // b) http://localhost:8080/in/user/settings -> should be redirected to in/user/settings + // 2. when automatically logged out: + // http://localhost:8080/login?redirect=/in/user/settings + // -> should be redirected to in/user/settings + var redirect; + if (router.currentRoute.value.redirectedFrom) { + redirect = router.currentRoute.value.redirectedFrom.path; + if (redirect === '/') { + redirect = mainRoute; + } + } else if ('redirect' in router.currentRoute.value.query) { + redirect = { path: router.currentRoute.value.query.redirect as string }; + } else { + redirect = mainRoute; + } void router.push(redirect); } else { // Login failed, notify and reset form