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:
Classic298 2026-10-21 19:13:22 +02:00 • committed by GitHub
parent 70cceb51b0
commit ffcb24824f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;