mirror of
https://github.com/open-webui/open-webui
synced 2025-05-20 21:25:21 +00:00
fix: block users from /workspace and /admin
This commit is contained in:
parent
4c1a9380e6
commit
c6d7f24542
@ -1,11 +1,21 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount, getContext } from 'svelte';
|
import { onMount, getContext } from 'svelte';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
import { WEBUI_NAME, showSidebar } from '$lib/stores';
|
import { WEBUI_NAME, showSidebar, user } from '$lib/stores';
|
||||||
import MenuLines from '$lib/components/icons/MenuLines.svelte';
|
import MenuLines from '$lib/components/icons/MenuLines.svelte';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
let loaded = false;
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
if ($user?.role !== 'admin') {
|
||||||
|
await goto('/');
|
||||||
|
}
|
||||||
|
loaded = true;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@ -14,6 +24,7 @@
|
|||||||
</title>
|
</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
|
{#if loaded}
|
||||||
<div
|
<div
|
||||||
class=" flex flex-col w-full min-h-screen max-h-screen {$showSidebar
|
class=" flex flex-col w-full min-h-screen max-h-screen {$showSidebar
|
||||||
? 'md:max-w-[calc(100%-260px)]'
|
? 'md:max-w-[calc(100%-260px)]'
|
||||||
@ -80,3 +91,4 @@
|
|||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount, getContext } from 'svelte';
|
import { onMount, getContext } from 'svelte';
|
||||||
|
import { WEBUI_NAME, showSidebar, functions, user } from '$lib/stores';
|
||||||
import { WEBUI_NAME, showSidebar, functions } from '$lib/stores';
|
|
||||||
import MenuLines from '$lib/components/icons/MenuLines.svelte';
|
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { getFunctions } from '$lib/apis/functions';
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
|
import MenuLines from '$lib/components/icons/MenuLines.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
let loaded = false;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
// functions.set(await getFunctions(localStorage.token));
|
if ($user?.role !== 'admin') {
|
||||||
|
await goto('/');
|
||||||
|
}
|
||||||
|
loaded = true;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -19,6 +24,7 @@
|
|||||||
</title>
|
</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
|
{#if loaded}
|
||||||
<div
|
<div
|
||||||
class=" flex flex-col w-full min-h-screen max-h-screen {$showSidebar
|
class=" flex flex-col w-full min-h-screen max-h-screen {$showSidebar
|
||||||
? 'md:max-w-[calc(100%-260px)]'
|
? 'md:max-w-[calc(100%-260px)]'
|
||||||
@ -62,7 +68,9 @@
|
|||||||
>
|
>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/documents')
|
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes(
|
||||||
|
'/workspace/documents'
|
||||||
|
)
|
||||||
? 'bg-gray-50 dark:bg-gray-850'
|
? 'bg-gray-50 dark:bg-gray-850'
|
||||||
: ''} transition"
|
: ''} transition"
|
||||||
href="/workspace/documents"
|
href="/workspace/documents"
|
||||||
@ -80,7 +88,9 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/functions')
|
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes(
|
||||||
|
'/workspace/functions'
|
||||||
|
)
|
||||||
? 'bg-gray-50 dark:bg-gray-850'
|
? 'bg-gray-50 dark:bg-gray-850'
|
||||||
: ''} transition"
|
: ''} transition"
|
||||||
href="/workspace/functions"
|
href="/workspace/functions"
|
||||||
@ -96,3 +106,4 @@
|
|||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user