From 40247326961455af3826d7831fa16ee67a667608 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Wed, 8 Apr 2026 13:08:46 +0200 Subject: [PATCH] fix: handle 403 on principal fetch without console error --- stores/account-security-store.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/stores/account-security-store.ts b/stores/account-security-store.ts index 10be9354..405d55d9 100644 --- a/stores/account-security-store.ts +++ b/stores/account-security-store.ts @@ -129,7 +129,20 @@ export const useAccountSecurityStore = create()((set, get) const response = await fetch('/api/account/stalwart/principal', { headers: getApiHeaders(), }); - if (!response.ok) throw new Error(`HTTP ${response.status}`); + if (!response.ok) { + if (response.status === 403) { + // User lacks permission to read principal (e.g. non-admin); treat as empty + set({ + displayName: '', + emails: [], + quota: 0, + roles: [], + isLoadingPrincipal: false, + }); + return; + } + throw new Error(`HTTP ${response.status}`); + } const data = await response.json(); const principal = data.data; set({