mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-28 06:22:33 +00:00
fix: Calendar page opens empty with an error when Calendar is turned off (#32837)
With Calendar switched off by an admin, or the calendar permission taken away, the sidebar entry was hidden but opening /calendar directly from a bookmark or the address bar still showed an empty month grid with a "401 Unauthorized" error. The page now sends these users to the home page, the same as Notes and Automations do. Fixes #32834
This commit is contained in:
parent
70cceb51b0
commit
ffcb24824f
1 changed files with 9 additions and 1 deletions
|
|
@ -2,7 +2,7 @@
|
|||
import { onMount, getContext, tick } from 'svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { goto } from '$app/navigation';
|
||||
import { WEBUI_NAME, mobile, showSidebar, user } from '$lib/stores';
|
||||
import { WEBUI_NAME, config, mobile, showSidebar, user } from '$lib/stores';
|
||||
import {
|
||||
getCalendars,
|
||||
getCalendarEvents,
|
||||
|
|
@ -202,6 +202,14 @@
|
|||
: `${MONTH_NAMES[currentDate.getMonth()]} ${currentDate.getFullYear()}`;
|
||||
|
||||
onMount(async () => {
|
||||
if (
|
||||
!$config?.features?.enable_calendar ||
|
||||
($user?.role !== 'admin' && !$user?.permissions?.features?.calendar)
|
||||
) {
|
||||
goto('/');
|
||||
return;
|
||||
}
|
||||
|
||||
await loadCalendars();
|
||||
await refresh();
|
||||
loaded = true;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue