Fix user preferences not being applied correctly after sign-in

This commit is contained in:
Bubka
2023-03-15 11:46:37 +01:00
parent 5ced8cbf0e
commit f359a1ade3
9 changed files with 70 additions and 22 deletions

View File

@ -1,4 +1,5 @@
import Vue from 'vue'
import i18n from './langs/i18n'
Vue.mixin({
@ -100,7 +101,23 @@ Vue.mixin({
setTheme(theme) {
document.documentElement.dataset.theme = theme;
}
},
applyPreferences(preferences) {
for (const preference in preferences) {
try {
this.$root.userPreferences[preference] = preferences[preference]
}
catch (e) {
console.log(e)
}
}
if (this.$root.userPreferences.lang != 'browser') {
i18n.locale = this.$root.userPreferences.lang
document.documentElement.lang = this.$root.userPreferences.lang
}
},
}
})

View File

@ -72,6 +72,7 @@
this.form.post('/user/login', {returnError: true})
.then(response => {
this.applyPreferences(response.data.preferences);
this.$router.push({ name: 'accounts', params: { toRefresh: true } })
})
.catch(error => {
@ -131,6 +132,7 @@
const publicKeyCredential = this.webauthn.parseOutgoingCredentials(credentials)
this.axios.post('/webauthn/login', publicKeyCredential, {returnError: true}).then(response => {
this.applyPreferences(response.data.preferences);
this.$router.push({ name: 'accounts', params: { toRefresh: true } })
})
.catch(error => {