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