fix: guest reload page to accessed MemberDashboard
This commit is contained in:
+17
-5
@@ -68,13 +68,12 @@ function App() {
|
||||
} else if (viewTourId) {
|
||||
setCurrentPage('tourDetail');
|
||||
} else {
|
||||
// Check if only guest token exists (no real login)
|
||||
const isGuestOnly = guestToken && !token;
|
||||
if (isGuestOnly) {
|
||||
// Guest user trying to access dashboard - redirect to landing
|
||||
// CRITICAL: Check for guest token FIRST - guests should NEVER access dashboard
|
||||
// regardless of whether they also have other tokens
|
||||
if (guestToken) {
|
||||
setCurrentPage('landing');
|
||||
} else if (loggedInUser) {
|
||||
// Real authenticated user
|
||||
// Real authenticated user (no guest token)
|
||||
if (loggedInUser.isAdmin) {
|
||||
setCurrentPage('admin');
|
||||
} else {
|
||||
@@ -229,6 +228,19 @@ function App() {
|
||||
}
|
||||
|
||||
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 (
|
||||
<MemberDashboard
|
||||
user={user}
|
||||
|
||||
Reference in New Issue
Block a user