auto-claude: subtask-2-1 - Simplify DashboardContent client-side auth check
Removed redundant client-side redirect logic from DashboardContent since server-side middleware now handles route protection (Phase 1 complete). Changes: - Removed redirect to login page from useEffect (now handled by middleware) - Renamed checkAuth to fetchUser (more accurate purpose) - Removed locale and router from useEffect dependencies (no longer needed) - Kept loading state and user fetching for display purposes - Component now trusts middleware protection and focuses on data display The component still: - Fetches user data for display (email, etc.) - Shows loading state during fetch - Handles logout functionality - Maintains existing UI/UX Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,21 +24,16 @@ export default function DashboardContent() {
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const checkAuth = async () => {
|
||||
const fetchUser = async () => {
|
||||
const supabase = createClient();
|
||||
const { data: { user } } = await supabase.auth.getUser();
|
||||
|
||||
if (!user) {
|
||||
router.push(`/${locale}/login`);
|
||||
return;
|
||||
}
|
||||
|
||||
setUser(user);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
checkAuth();
|
||||
}, [locale, router]);
|
||||
fetchUser();
|
||||
}, []);
|
||||
|
||||
const handleLogout = async () => {
|
||||
const supabase = createClient();
|
||||
|
||||
Reference in New Issue
Block a user