Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
c6d7f245
Commit
c6d7f245
authored
Aug 02, 2024
by
Timothy J. Baek
Browse files
fix: block users from /workspace and /admin
parent
4c1a9380
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
112 deletions
+135
-112
src/routes/(app)/admin/+layout.svelte
src/routes/(app)/admin/+layout.svelte
+55
-43
src/routes/(app)/workspace/+layout.svelte
src/routes/(app)/workspace/+layout.svelte
+80
-69
No files found.
src/routes/(app)/admin/+layout.svelte
View file @
c6d7f245
<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,11 +24,12 @@
...
@@ -14,11 +24,12 @@
</title>
</title>
</svelte:head>
</svelte:head>
<div
{#if loaded}
<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)]'
: ''}"
: ''}"
>
>
<div class=" px-4 pt-3 mt-0.5 mb-1">
<div class=" px-4 pt-3 mt-0.5 mb-1">
<div class=" flex items-center gap-1">
<div class=" flex items-center gap-1">
<div class="{$showSidebar ? 'md:hidden' : ''} mr-1 self-start flex flex-none items-center">
<div class="{$showSidebar ? 'md:hidden' : ''} mr-1 self-start flex flex-none items-center">
...
@@ -79,4 +90,5 @@
...
@@ -79,4 +90,5 @@
<div class=" py-1 px-5 flex-1 max-h-full overflow-y-auto">
<div class=" py-1 px-5 flex-1 max-h-full overflow-y-auto">
<slot />
<slot />
</div>
</div>
</div>
</div>
{/if}
src/routes/(app)/workspace/+layout.svelte
View file @
c6d7f245
<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 { page } from '$app/stores';
import { goto } from '$app/navigation';
import { WEBUI_NAME, showSidebar, functions } 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 { getFunctions } from '$lib/apis/functions';
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,11 +24,12 @@
...
@@ -19,11 +24,12 @@
</title>
</title>
</svelte:head>
</svelte:head>
<div
{#if loaded}
<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)]'
: ''}"
: ''}"
>
>
<div class=" px-4 pt-3 mt-0.5 mb-1">
<div class=" px-4 pt-3 mt-0.5 mb-1">
<div class=" flex items-center gap-1">
<div class=" flex items-center gap-1">
<div class="{$showSidebar ? 'md:hidden' : ''} mr-1 self-start flex flex-none items-center">
<div class="{$showSidebar ? 'md:hidden' : ''} mr-1 self-start flex flex-none items-center">
...
@@ -62,7 +68,9 @@
...
@@ -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 @@
...
@@ -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"
...
@@ -95,4 +105,5 @@
...
@@ -95,4 +105,5 @@
<div class=" py-1 px-5 flex-1 max-h-full overflow-y-auto">
<div class=" py-1 px-5 flex-1 max-h-full overflow-y-auto">
<slot />
<slot />
</div>
</div>
</div>
</div>
{/if}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment