Merge pull request #2073 from Human-Connection/Laod_saved_Laguage_and_select

1931 - after successful login the saved language of the user is set
This commit is contained in:
mattwr18 2019-11-11 11:43:12 +01:00 committed by GitHub
commit 52bdfa7c48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

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

View File

@ -84,6 +84,7 @@ export const actions = {
role role
about about
locationName locationName
locale
contributionsCount contributionsCount
commentedCount commentedCount
allowEmbedIframes allowEmbedIframes

View File

@ -13,6 +13,7 @@ const currentUser = {
email: 'user@example.org', email: 'user@example.org',
avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/mutu_krish/128.jpg', avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/mutu_krish/128.jpg',
role: 'user', role: 'user',
locale: 'de',
} }
const successfulLoginResponse = { data: { login: token } } const successfulLoginResponse = { data: { login: token } }
const successfulCurrentUserResponse = { data: { currentUser } } const successfulCurrentUserResponse = { data: { currentUser } }
@ -126,6 +127,7 @@ describe('actions', () => {
email: 'user@example.org', email: 'user@example.org',
avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/mutu_krish/128.jpg', avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/mutu_krish/128.jpg',
role: 'user', role: 'user',
locale: 'de',
}, },
], ],
]), ]),