diff options
author | dartcafe <github@dartcafe.de> | 2022-06-24 11:22:47 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2022-06-24 11:22:47 +0300 |
commit | b0b6bde715fad5290e61791d52e9bd4773654a9e (patch) | |
tree | 61c5e11c617e74ed69118d4ac6cf5d2e49b6459a /src | |
parent | be746ac78dde8dee7eefd6581de02daa20243a92 (diff) |
fix redirect
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/js/components/Poll/PublicRegisterModal.vue | 3 | ||||
-rw-r--r-- | src/js/router.js | 5 | ||||
-rw-r--r-- | src/js/store/modules/share.js | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/js/components/Poll/PublicRegisterModal.vue b/src/js/components/Poll/PublicRegisterModal.vue index 156fbbd1..7a121c1d 100644 --- a/src/js/components/Poll/PublicRegisterModal.vue +++ b/src/js/components/Poll/PublicRegisterModal.vue @@ -36,7 +36,7 @@ focus @submit="submitRegistration" /> - <CheckboxRadioSwitch :checked.sync="saveCookie"> + <CheckboxRadioSwitch v-if="share.type === 'public'" :checked.sync="saveCookie"> {{ t('polls', 'Remember me for 30 days') }} </CheckboxRadioSwitch> @@ -318,6 +318,7 @@ export default { if (this.registrationIsValid) { try { const response = await this.$store.dispatch('share/register', { userName: this.userName, emailAddress: this.emailAddress, saveCookie: this.saveCookie }) + if (this.$route.params.token === response.token) { this.$store.dispatch({ type: 'poll/get', pollId: this.$route.params.id, token: this.$route.params.token }) this.closeModal() diff --git a/src/js/router.js b/src/js/router.js index c6485944..1ddf9473 100644 --- a/src/js/router.js +++ b/src/js/router.js @@ -58,9 +58,12 @@ async function validateToken(to, from, next) { if (getCurrentUser()) { // reroute to the internal vote page, if the user is logged in next({ name: 'vote', params: { id: response.data.share.pollId } }) + } else { + const privateToken = getCookie(to.params.token) - if (privateToken) { + + if (privateToken && to.params.token !== privateToken) { // extend expiry time for 30 days after successful access const cookieExpiration = (30 * 24 * 60 * 1000) setCookie(to.params.token, privateToken, cookieExpiration) diff --git a/src/js/store/modules/share.js b/src/js/store/modules/share.js index 9601f1a0..a1c53a8d 100644 --- a/src/js/store/modules/share.js +++ b/src/js/store/modules/share.js @@ -91,7 +91,7 @@ const actions = { emailAddress: payload.emailAddress, }) - if (payload.saveCookie) { + if (payload.saveCookie && context.state.type === 'public') { const cookieExpiration = (30 * 24 * 60 * 1000) setCookie(context.rootState.route.params.token, response.data.share.token, cookieExpiration) } |