clean sidebar 3

This commit is contained in:
alma 2025-04-18 10:09:10 +02:00
parent 693ca68861
commit e5dbd1c67c
2 changed files with 13 additions and 5 deletions

View File

@ -57,10 +57,13 @@ export function Sidebar({ isOpen, onClose }: SidebarProps) {
pathname
});
// Redirect to signin if no session
// Show loading state while session is being checked
if (status === 'loading') {
return null;
}
// Show nothing if not authenticated (middleware will handle redirect)
if (status === 'unauthenticated') {
console.log('No session, redirecting to signin');
router.push('/signin');
return null;
}

View File

@ -29,8 +29,13 @@ export default withAuth(
return true;
}
// Require authentication for protected API endpoints
return !!token;
// For protected API endpoints, check if the request has a valid session
if (!token) {
// Return 401 for API routes instead of redirecting
return false;
}
return true;
}
// For all other routes, require a valid token