logout issues # 2
This commit is contained in:
@@ -48,18 +48,7 @@ export default function ProtectedRoute({ children }: ProtectedRouteProps) {
|
||||
trackLoading('auth-loading', loading);
|
||||
}, [loading]);
|
||||
|
||||
// Validate account + plan whenever auth/user changes
|
||||
useEffect(() => {
|
||||
if (!isAuthenticated) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user?.account) {
|
||||
setErrorMessage('This user is not linked to an account. Please contact support.');
|
||||
logout();
|
||||
return;
|
||||
}
|
||||
}, [isAuthenticated, user, logout]);
|
||||
// Account/plan validation removed - backend middleware handles this on API calls
|
||||
|
||||
// Immediate check on mount: if loading is true, reset it immediately
|
||||
useEffect(() => {
|
||||
|
||||
@@ -68,18 +68,7 @@ export default function SiteSwitcher({ hiddenPaths }: SiteSwitcherProps) {
|
||||
shouldHide = hiddenPathsToUse.some(path => location.pathname.startsWith(path));
|
||||
}
|
||||
|
||||
// Refresh user data when component mounts or user changes
|
||||
// This ensures we have latest account/plan info for proper site filtering
|
||||
useEffect(() => {
|
||||
if (isAuthenticated && user) {
|
||||
// Refresh user data to get latest account/plan changes
|
||||
// This is important so site filtering works correctly
|
||||
refreshUser().catch((error) => {
|
||||
// Silently fail - user might still be valid, just couldn't refresh
|
||||
console.debug('SiteSwitcher: Failed to refresh user (non-critical):', error);
|
||||
});
|
||||
}
|
||||
}, [isAuthenticated]); // Only refresh when auth state changes, not on every render
|
||||
// User refresh removed - data loads on-demand from API calls
|
||||
|
||||
useEffect(() => {
|
||||
if (shouldHide) {
|
||||
|
||||
Reference in New Issue
Block a user