fix: guest reload page to accessed MemberDashboard

This commit is contained in:
2026-06-22 12:45:29 +07:00
parent 01d6d7439f
commit 29c19c6372
16 changed files with 33 additions and 19 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 756 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 KiB

File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -6,7 +6,7 @@
<link rel="icon" type="image/x-icon" href="/favicon.ico" /> <link rel="icon" type="image/x-icon" href="/favicon.ico" />
<script src="https://accounts.google.com/gsi/client" async defer></script> <script src="https://accounts.google.com/gsi/client" async defer></script>
<title>Travel Planner</title> <title>Travel Planner</title>
<script type="module" crossorigin src="/assets/index-DtsqetSG.js"></script> <script type="module" crossorigin src="/assets/index-BwN9EkVY.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-sqDjZKsa.css"> <link rel="stylesheet" crossorigin href="/assets/index-sqDjZKsa.css">
</head> </head>
<body> <body>
+17 -5
View File
@@ -68,13 +68,12 @@ function App() {
} else if (viewTourId) { } else if (viewTourId) {
setCurrentPage('tourDetail'); setCurrentPage('tourDetail');
} else { } else {
// Check if only guest token exists (no real login) // CRITICAL: Check for guest token FIRST - guests should NEVER access dashboard
const isGuestOnly = guestToken && !token; // regardless of whether they also have other tokens
if (isGuestOnly) { if (guestToken) {
// Guest user trying to access dashboard - redirect to landing
setCurrentPage('landing'); setCurrentPage('landing');
} else if (loggedInUser) { } else if (loggedInUser) {
// Real authenticated user // Real authenticated user (no guest token)
if (loggedInUser.isAdmin) { if (loggedInUser.isAdmin) {
setCurrentPage('admin'); setCurrentPage('admin');
} else { } else {
@@ -229,6 +228,19 @@ function App() {
} }
if (currentPage === 'dashboard') { if (currentPage === 'dashboard') {
// SECURITY: Prevent any guest from accessing dashboard
const guestToken = localStorage.getItem('guest_token');
if (guestToken) {
console.warn('[App] Guest user attempted to access dashboard - forcing redirect to landing');
setCurrentPage('landing');
return (
<LandingPage
onLoginSuccess={handleLoginSuccess}
onGoToSignup={() => setCurrentPage('signup')}
/>
);
}
return ( return (
<MemberDashboard <MemberDashboard
user={user} user={user}
+9 -7
View File
@@ -142,19 +142,21 @@ export const AddPhotoModal: React.FC<AddPhotoModalProps> = ({ isOpen, onClose, t
setSelectedFiles([]); setSelectedFiles([]);
setPreviews([]); setPreviews([]);
// For public users: redirect to landing page after upload // Refresh tour data (applies to both authenticated and public users)
// For authenticated users: refresh tour data and close modal // This ensures newly uploaded photos appear immediately without requiring a page reload
fetchTour(tourId);
if (onSuccess) onSuccess();
// For public users: redirect to landing page after upload (after data refresh)
// For authenticated users: close modal and show updated tour
if (isPublicView) { if (isPublicView) {
onClose(); onClose();
// Give time for notification to show before redirecting // Give time for tour data to refresh before redirecting
// Set flag so App.tsx knows to redirect to landing even if user is logged in
setTimeout(() => { setTimeout(() => {
localStorage.setItem('fromPublicUpload', 'true'); localStorage.setItem('fromPublicUpload', 'true');
window.location.href = '/'; window.location.href = '/';
}, 1000); }, 1500);
} else { } else {
fetchTour(tourId);
if (onSuccess) onSuccess();
onClose(); onClose();
} }
} catch (error) { } catch (error) {