mirror of
https://github.com/abhinavxd/libredesk.git
synced 2025-11-02 04:53:41 +00:00
store public config in pinia store
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user