diff --git a/src/lib/components/chat/Settings/Account.svelte b/src/lib/components/chat/Settings/Account.svelte index 7765f81f3..c47391a6e 100644 --- a/src/lib/components/chat/Settings/Account.svelte +++ b/src/lib/components/chat/Settings/Account.svelte @@ -109,10 +109,17 @@ webhookUrl = $settings?.notifications?.webhook_url ?? ''; - APIKey = await getAPIKey(localStorage.token).catch((error) => { - console.log(error); - return ''; - }); + // Only fetch API key if the feature is enabled and user has permission + if ( + user && + ($config?.features?.enable_api_keys ?? true) && + (user?.role === 'admin' || (user?.permissions?.features?.api_keys ?? false)) + ) { + APIKey = await getAPIKey(localStorage.token).catch((error) => { + console.log(error); + return ''; + }); + } loaded = true; }); diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index 055970bc9..5e9ed83a2 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -455,7 +455,13 @@ } if (value) { - await initChannels(); + // Only fetch channels if the feature is enabled and user has permission + if ( + $config?.features?.enable_channels && + ($user?.role === 'admin' || ($user?.permissions?.features?.channels ?? true)) + ) { + await initChannels(); + } await initChatList(); } })