From 9c1e79b5a51aa2518df9f70713560564241c1c5e Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 9 Jul 2025 09:03:14 +0200 Subject: [PATCH] Fix gallery issues: user uploads, error messages, and translations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix user upload feature not showing in gallery - Add allow_user_uploads and upload_category_id to auth response - These fields are required for the gallery to show the upload button - Improve gallery login error messages - Add specific translations for wrong password vs rate limiting - Map backend error messages to user-friendly translations - Added auth.wrongPassword and auth.tooManyAttempts keys - Gallery pages already have full translation support - GalleryPage and GalleryView use i18n properly - All text is translated based on selected language These fixes resolve: 1. User upload button not showing even when enabled 2. Generic error messages for wrong passwords 3. No feedback for rate limiting 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- backend/src/routes/auth.js | 4 +++- frontend/src/i18n/locales/de.json | 2 ++ frontend/src/i18n/locales/en.json | 2 ++ frontend/src/pages/GalleryPage.tsx | 11 ++++++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/backend/src/routes/auth.js b/backend/src/routes/auth.js index 90165dd..cbfb0ab 100644 --- a/backend/src/routes/auth.js +++ b/backend/src/routes/auth.js @@ -115,7 +115,9 @@ router.post('/gallery/verify', [ event_date: event.event_date, welcome_message: event.welcome_message, color_theme: event.color_theme, - expires_at: event.expires_at + expires_at: event.expires_at, + allow_user_uploads: event.allow_user_uploads, + upload_category_id: event.upload_category_id } }); } catch (error) { diff --git a/frontend/src/i18n/locales/de.json b/frontend/src/i18n/locales/de.json index eccdee5..b6cc87b 100644 --- a/frontend/src/i18n/locales/de.json +++ b/frontend/src/i18n/locales/de.json @@ -99,6 +99,8 @@ "enterPassword": "Galerie-Passwort eingeben", "passwordPlaceholder": "Geben Sie das Galerie-Passwort ein", "invalidPassword": "Ungültiges Passwort", + "wrongPassword": "Falsches Passwort. Bitte überprüfen Sie Ihr Passwort und versuchen Sie es erneut.", + "tooManyAttempts": "Zu viele fehlgeschlagene Anmeldeversuche. Bitte versuchen Sie es später erneut.", "sessionExpired": "Sitzung abgelaufen", "pleaseEnterPassword": "Bitte geben Sie ein Passwort ein", "passwordHint": "Das Passwort wurde vom Veranstalter bereitgestellt. Kontaktieren Sie ihn, wenn Sie es nicht haben." diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index f87e56f..0ccc1d6 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -99,6 +99,8 @@ "enterPassword": "Enter Gallery Password", "passwordPlaceholder": "Enter the gallery password", "invalidPassword": "Invalid password", + "wrongPassword": "Incorrect password. Please check your password and try again.", + "tooManyAttempts": "Too many failed login attempts. Please try again later.", "sessionExpired": "Session expired", "pleaseEnterPassword": "Please enter a password", "passwordHint": "The password was provided by the event organizer. Contact them if you don't have it." diff --git a/frontend/src/pages/GalleryPage.tsx b/frontend/src/pages/GalleryPage.tsx index ebf8284..ddfeb34 100644 --- a/frontend/src/pages/GalleryPage.tsx +++ b/frontend/src/pages/GalleryPage.tsx @@ -66,7 +66,16 @@ export const GalleryPage: React.FC = () => { success: true }); } catch (error: any) { - setLoginError(error.response?.data?.error || t('auth.invalidPassword')); + const errorMessage = error.response?.data?.error || 'Invalid password'; + + // Map backend error messages to user-friendly translations + if (errorMessage.toLowerCase().includes('invalid password')) { + setLoginError(t('auth.wrongPassword')); + } else if (error.response?.status === 429 || errorMessage.toLowerCase().includes('too many')) { + setLoginError(t('auth.tooManyAttempts')); + } else { + setLoginError(t('auth.invalidPassword')); + } // Track failed password entry analyticsService.trackGalleryEvent('password_entry', {