after successful login the saved language of the user is set

This commit is contained in:
ogerly 2019-10-29 11:05:49 +01:00
parent b644bbc4d9
commit 7d2801a636
2 changed files with 15 additions and 0 deletions

View File

@ -7,12 +7,18 @@
<script>
import LoginForm from '~/components/LoginForm/LoginForm.vue'
import { VERSION } from '~/constants/terms-and-conditions-version.js'
import { mapGetters } from 'vuex'
export default {
layout: 'no-header',
components: {
LoginForm,
},
computed: {
...mapGetters({
user: 'auth/user',
}),
},
asyncData({ store, redirect }) {
if (store.getters['auth/user'].termsAndConditionsAgreedVersion === VERSION) {
redirect('/')
@ -20,6 +26,11 @@ export default {
},
methods: {
handleSuccess() {
const currentLocale = this.$i18n.locale()
const userSettingLocale = this.user.locale
if (currentLocale !== userSettingLocale) {
this.$i18n.set(userSettingLocale)
}
this.$router.replace(this.$route.query.path || '/')
},
},

View File

@ -46,6 +46,9 @@ export const getters = {
termsAndConditionsAgreed(state) {
return state.user && state.user.termsAndConditionsAgreedVersion === VERSION
},
locale(state) {
return state.locale
},
}
export const actions = {
@ -84,6 +87,7 @@ export const actions = {
role
about
locationName
locale
contributionsCount
commentedCount
allowEmbedIframes