From c94b6268cfbd26eb57a537302f9f7596cefa9350 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 15 Jul 2025 09:07:30 +0200 Subject: [PATCH] fix: resolve gallery authentication and redirect issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix useWatermarkSettings hook to use public API endpoint instead of admin endpoint - Add hero_photo_id to gallery authentication response - Prevent 401 errors on gallery pages from redirecting to admin login - Gallery pages now correctly fetch settings without requiring admin auth The main issue was that gallery pages were calling admin-only endpoints which triggered 401 errors and caused redirects to the admin login page. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- backend/src/routes/auth.js | 3 ++- frontend/src/hooks/useWatermarkSettings.ts | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/src/routes/auth.js b/backend/src/routes/auth.js index 76f8321..08ecd07 100644 --- a/backend/src/routes/auth.js +++ b/backend/src/routes/auth.js @@ -119,7 +119,8 @@ router.post('/gallery/verify', [ color_theme: event.color_theme, expires_at: event.expires_at, allow_user_uploads: event.allow_user_uploads, - upload_category_id: event.upload_category_id + upload_category_id: event.upload_category_id, + hero_photo_id: event.hero_photo_id } }); } catch (error) { diff --git a/frontend/src/hooks/useWatermarkSettings.ts b/frontend/src/hooks/useWatermarkSettings.ts index 06528be..5484429 100644 --- a/frontend/src/hooks/useWatermarkSettings.ts +++ b/frontend/src/hooks/useWatermarkSettings.ts @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react'; -import { settingsService } from '../services/settings.service'; +import { api } from '../config/api'; export function useWatermarkSettings() { const [watermarkEnabled, setWatermarkEnabled] = useState(false); @@ -8,11 +8,13 @@ export function useWatermarkSettings() { useEffect(() => { const fetchSettings = async () => { try { - const settings = await settingsService.getSettingsByType('branding'); - const brandingSettings = settingsService.formatBrandingSettings(settings); - setWatermarkEnabled(brandingSettings.watermark_enabled); + // Use public settings endpoint that doesn't require authentication + const response = await api.get('/public/settings'); + setWatermarkEnabled(response.data.branding_watermark_enabled || false); } catch (error) { console.error('Failed to fetch watermark settings:', error); + // Default to false if we can't fetch settings + setWatermarkEnabled(false); } finally { setLoading(false); }