store public config in pinia store

This commit is contained in:
Abhinav Raut
2025-09-01 03:20:09 +05:30
parent 35ad00ec51
commit 3ce3c5e0ee
5 changed files with 18 additions and 9 deletions

View File

@@ -48,7 +48,7 @@ func handleGetConfig(r *fastglue.Request) error {
"provider": provider.Provider,
"provider_url": provider.ProviderURL,
"client_id": provider.ClientID,
"logo": provider.ProviderLogoURL,
"logo_url": provider.ProviderLogoURL,
"enabled": provider.Enabled,
"redirect_uri": provider.RedirectURI,
}
@@ -57,7 +57,7 @@ func handleGetConfig(r *fastglue.Request) error {
}
// Add SSO providers to the response
publicSettings["sso_providers"] = enabledProviders
publicSettings["app.sso_providers"] = enabledProviders
return r.SendEnvelope(publicSettings)
}

View File

@@ -14,12 +14,12 @@ describe('Login Component', () => {
"app.lang": "en",
"app.logo_url": "http://localhost:9000/logo.png",
"app.site_name": "Libredesk",
"sso_providers": [
"app.sso_providers": [
{
"client_id": "xx",
"enabled": true,
"id": 1,
"logo": "/images/google-logo.png",
"logo_url": "/images/google-logo.png",
"name": "Google",
"provider": "Google",
"provider_url": "https://accounts.google.com",

View File

@@ -44,6 +44,10 @@ async function initApp () {
// Fetch and store app settings in store
const settingsStore = useAppSettingsStore()
// Store the public config in the store
settingsStore.setPublicConfig(config)
try {
const generalSettings = (await api.getSettings('general')).data.data
settingsStore.setSettings(generalSettings)

View File

@@ -2,11 +2,15 @@ import { defineStore } from 'pinia'
export const useAppSettingsStore = defineStore('settings', {
state: () => ({
settings: {}
settings: {},
public_config: {}
}),
actions: {
setSettings (newSettings) {
this.settings = newSettings
},
setPublicConfig (newPublicConfig) {
this.public_config = newPublicConfig
}
}
})

View File

@@ -9,7 +9,7 @@
<CardContent class="p-6 space-y-6">
<div class="space-y-2 text-center">
<CardTitle class="text-3xl font-bold text-foreground">
{{ appSettingsStore.settings?.['app.site_name'] || 'Libredesk' }}
{{ appSettingsStore.public_config?.['app.site_name'] || 'LIBREDESK' }}
</CardTitle>
<p class="text-muted-foreground">{{ t('auth.signIn') }}</p>
</div>
@@ -161,9 +161,10 @@ onMounted(async () => {
const fetchOIDCProviders = async () => {
try {
// Also fetched in `main.js`, can be fixed later
const resp = await api.getConfig()
oidcProviders.value = resp.data.data.sso_providers || []
const config = appSettingsStore.public_config
if (config && config['app.sso_providers']) {
oidcProviders.value = config['app.sso_providers'] || []
}
} catch (error) {
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
variant: 'destructive',