diff --git a/src/components/home/contentNoAuth.vue b/src/components/home/contentNoAuth.vue index a4e5fa0e..08483506 100644 --- a/src/components/home/contentNoAuth.vue +++ b/src/components/home/contentNoAuth.vue @@ -19,6 +19,7 @@ import {mapState} from 'vuex' import logoUrl from '@/assets/logo-full.svg' +import { saveLastVisited } from '@/helpers/saveLastVisited' export default { name: 'contentNoAuth', @@ -46,6 +47,7 @@ export default { localStorage.getItem('passwordResetToken') === null && localStorage.getItem('emailConfirmToken') === null ) { + saveLastVisited(this.$route.name, this.$route.params) this.$router.push({name: 'user.login'}) } }, diff --git a/src/helpers/saveLastVisited.ts b/src/helpers/saveLastVisited.ts new file mode 100644 index 00000000..fc731d26 --- /dev/null +++ b/src/helpers/saveLastVisited.ts @@ -0,0 +1,18 @@ +const LAST_VISITED_KEY = 'lastVisited' + +export const saveLastVisited = (name: string, params: object) => { + localStorage.setItem(LAST_VISITED_KEY, JSON.stringify({name, params})) +} + +export const getLastVisited = () => { + const lastVisited = localStorage.getItem(LAST_VISITED_KEY) + if (lastVisited === null) { + return null + } + + return JSON.parse(lastVisited) +} + +export const clearLastVisited = () => { + return localStorage.removeItem(LAST_VISITED_KEY) +} diff --git a/src/views/user/Login.vue b/src/views/user/Login.vue index 066b7229..4efa9636 100644 --- a/src/views/user/Login.vue +++ b/src/views/user/Login.vue @@ -104,13 +104,13 @@