Thx page shows content dependent of route from

This commit is contained in:
Moriz Wahl 2021-05-19 01:40:29 +02:00
parent 41ba384c51
commit 76c7708829
5 changed files with 62 additions and 4 deletions

View File

@ -85,7 +85,9 @@
}, },
"thx": { "thx": {
"title": "Danke!", "title": "Danke!",
"subtitle": "Wir haben dir eine eMail gesendet." "email": "Wir haben dir eine eMail gesendet.",
"reset": "Dein Passwort wurde geändert",
"register": "Du bist jetzt regisriert"
}, },
"overview":{ "overview":{
"account_overview":"Kontoübersicht", "account_overview":"Kontoübersicht",

View File

@ -85,7 +85,9 @@
}, },
"thx": { "thx": {
"title": "Thank you!", "title": "Thank you!",
"subtitle": "We have sent you an email." "email": "We have sent you an email.",
"reset": "Your password has been changed",
"register": "You are registred now"
}, },
"overview":{ "overview":{
"account_overview":"Account overview", "account_overview":"Account overview",

View File

@ -49,6 +49,14 @@ const routes = [
{ {
path: '/thx', path: '/thx',
component: () => import('../views/Pages/thx.vue'), component: () => import('../views/Pages/thx.vue'),
beforeEnter: (to, from, next) => {
const validFrom = ['/password', '/reset', '/register']
if (!validFrom.includes(from.path)) {
next({ path: '/login' })
} else {
next()
}
},
}, },
{ {
path: '/password', path: '/password',

View File

@ -107,6 +107,10 @@ export default {
const result = await loginAPI.changePassword(this.sessionId, this.email, this.password) const result = await loginAPI.changePassword(this.sessionId, this.email, this.password)
if (result.success) { if (result.success) {
this.password = '' this.password = ''
this.$store.dispatch('login', {
sessionId: result.result.data.session_id,
email: result.result.data.user.email,
})
this.$router.push('/thx') this.$router.push('/thx')
} else { } else {
alert(result.result.message) alert(result.result.message)

View File

@ -5,12 +5,54 @@
<b-container> <b-container>
<div class="header-body text-center mb-7"> <div class="header-body text-center mb-7">
<p class="h1">{{ $t('site.thx.title') }}</p> <p class="h1">{{ $t('site.thx.title') }}</p>
<p class="h4">{{ $t('site.thx.subtitle') }}</p> <p class="h4">{{ $t(displaySetup.subtitle) }}</p>
<hr /> <hr />
<b-button to="/login">{{ $t('login') }}</b-button> <b-button :to="displaySetup.linkTo">{{ $t(displaySetup.button) }}</b-button>
</div> </div>
</b-container> </b-container>
</div> </div>
<!-- Page content --> <!-- Page content -->
</div> </div>
</template> </template>
<script>
const textFields = {
'/password': {
subtitle: 'site.thx.email',
button: 'login',
linkTo: '/login',
},
'/reset': {
subtitle: 'site.thx.reset',
button: 'site.login.signin',
linkTo: '/overview',
},
'/register': {
subtitle: 'site.thx.register',
button: 'site.login.signin',
linkTo: '/overview',
},
}
export default {
name: 'Thx',
data() {
return {
comingFrom: null,
displaySetup: {},
}
},
beforeRouteEnter(to, from, next) {
next((vm) => {
vm.comingFrom = from.path
})
},
methods: {
setupDisplay() {
this.displaySetup = textFields[this.comingFrom]
},
},
created() {
this.setupDisplay()
},
}
</script>