Mercurial > gemma
changeset 2825:d6c90d2c8c8d
router: when not logged in the chosen route is temporary cached and after successful login restored and chache cleared
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 27 Mar 2019 12:36:15 +0100 |
parents | d7c4169516fa |
children | f7ae108c2838 |
files | client/src/router.js client/src/store/application.js |
diffstat | 2 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/router.js Wed Mar 27 12:19:14 2019 +0100 +++ b/client/src/router.js Wed Mar 27 12:36:15 2019 +0100 @@ -233,16 +233,23 @@ store.commit("reset"); store.commit("user/clearAuth"); } + const { tempRoute } = store.state.application; const requiresAuth = to.matched.some(record => record.meta.requiresAuth); const loggedIn = store.state.user.isAuthenticated; const authRequired = requiresAuth && !(loggedIn || sessionStillActive(expiresFromPastSession)); if (authRequired) { + store.commit("application/setTempRoute", to.path); next("/login"); - } else if (!authRequired) { - next(); } else { - next(); + if (tempRoute) { + const target = tempRoute; + store.commit("application/setTempRoute", ""); + next({ + path: target, + replace: true + }); + } else next(); } });
--- a/client/src/store/application.js Wed Mar 27 12:19:14 2019 +0100 +++ b/client/src/store/application.js Wed Mar 27 12:36:15 2019 +0100 @@ -42,7 +42,8 @@ expandToolbar: false, countries: ["AT", "SK", "HU", "HR", "RS", "BiH", "BG", "RO", "UA"], searchQuery: "", - version + version, + tempRoute: "" }; }; @@ -74,6 +75,9 @@ } }, mutations: { + setTempRoute: (state, tempRoute) => { + state.tempRoute = tempRoute; + }, popup: (state, popup) => { state.popup = popup; },