fix(auth): useLogin maps login response to User, ProtectedRoute calls useAuth()

This commit is contained in:
Agent Zero
2026-08-16 23:32:07 +02:00
parent f265eef5ae
commit c3595a1bac
2 changed files with 16 additions and 1 deletions
+4
View File
@@ -1,11 +1,15 @@
import React from 'react';
import { Navigate, useLocation } from 'react-router-dom';
import { useAuthStore } from '@/store/authStore';
import { useAuth } from '@/hooks/useAuth';
export function ProtectedRoute({ children }: { children: React.ReactNode }) {
const { isAuthenticated } = useAuthStore();
const location = useLocation();
// Load user data on mount (handles page refresh)
useAuth();
if (!isAuthenticated) {
return <Navigate to="/login" state={{ from: location }} replace />;
}