1
0

feat: do not save language on the server when in demo mode

When the demo mode is enabled, people set the language to their own language - which is understandable. However, this is really confusing for other people when they log in and the language is something unexpected.
This change overrides the configured language when saving it while Vikunja is in demo mode.
This commit is contained in:
kolaente 2024-05-07 18:39:50 +02:00
parent 6e759b3bee
commit e1dcf2e859
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
2 changed files with 17 additions and 10 deletions

View File

@ -22,6 +22,6 @@ export interface IUserSettings extends IAbstract {
defaultProjectId: undefined | IProject['id'] defaultProjectId: undefined | IProject['id']
weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6 weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6
timezone: string timezone: string
language: SupportedLocale language: SupportedLocale | null
frontendSettings: IFrontendSettings frontendSettings: IFrontendSettings
} }

View File

@ -37,6 +37,8 @@ function redirectToProviderIfNothingElseIsEnabled() {
} }
export const useAuthStore = defineStore('auth', () => { export const useAuthStore = defineStore('auth', () => {
const configStore = useConfigStore()
const authenticated = ref(false) const authenticated = ref(false)
const isLinkShareAuth = ref(false) const isLinkShareAuth = ref(false)
const needsTotpPasscode = ref(false) const needsTotpPasscode = ref(false)
@ -185,8 +187,7 @@ export const useAuthStore = defineStore('auth', () => {
const HTTP = HTTPFactory() const HTTP = HTTPFactory()
setIsLoading(true) setIsLoading(true)
const {auth} = useConfigStore() const fullProvider: IProvider = configStore.auth.openidConnect.providers.find((p: IProvider) => p.key === provider)
const fullProvider: IProvider = auth.openidConnect.providers.find((p: IProvider) => p.key === provider)
const data = { const data = {
code: code, code: code,
@ -357,8 +358,15 @@ export const useAuthStore = defineStore('auth', () => {
const cancel = setModuleLoading(setIsLoadingGeneralSettings) const cancel = setModuleLoading(setIsLoadingGeneralSettings)
try { try {
const updateSettingsPromise = userSettingsService.update(settings) let settingsUpdate = {...settings}
setUserSettings({...settings}) if (configStore.demoModeEnabled) {
settingsUpdate = {
...settingsUpdate,
language: null,
}
}
const updateSettingsPromise = userSettingsService.update(settingsUpdate)
setUserSettings(settingsUpdate)
await setLanguage(settings.language) await setLanguage(settings.language)
await updateSettingsPromise await updateSettingsPromise
if (showMessage) { if (showMessage) {
@ -403,13 +411,12 @@ export const useAuthStore = defineStore('auth', () => {
await checkAuth() await checkAuth()
// if configured, redirect to OIDC Provider on logout // if configured, redirect to OIDC Provider on logout
const {auth} = useConfigStore()
if ( if (
auth.local.enabled === false && configStore.auth.local.enabled === false &&
auth.openidConnect.enabled && configStore.auth.openidConnect.enabled &&
auth.openidConnect.providers?.length === 1) configStore.auth.openidConnect.providers?.length === 1)
{ {
redirectToProviderOnLogout(auth.openidConnect.providers[0]) redirectToProviderOnLogout(configStore.auth.openidConnect.providers[0])
} }
} }