INSIGHT-MVP/packages/frontend/src/shell/App.tsx
Thomas Reitz 779d90ca43 feat: add user profile page with 2FA management and password change
Backend:
- POST /auth/2fa/setup - generate TOTP secret + QR code (temp Redis storage)
- POST /auth/2fa/enable - verify TOTP code and activate 2FA
- POST /auth/2fa/disable - deactivate 2FA (requires password)
- PATCH /users/me - update own profile (firstName, lastName)
- POST /users/me/change-password - change own password

Frontend:
- New ProfilePage with 3 sections: personal info, password, 2FA
- QR code display for Authenticator app setup
- Clickable user info in sidebar navigates to /profile
- AuthContext extended with twoFactorEnabled + refreshUser

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:24:44 +01:00

53 lines
1.5 KiB
TypeScript

import { Routes, Route, Navigate } from 'react-router-dom';
import { useAuth } from '../auth/AuthContext';
import { LoginPage } from '../auth/LoginPage';
import { AppLayout } from './AppLayout';
import { DashboardPage } from './DashboardPage';
import { AdminUsersPage } from '../admin/AdminUsersPage';
import { AdminTenantsPage } from '../admin/AdminTenantsPage';
import { ProfilePage } from '../profile/ProfilePage';
function PrivateRoute({ children }: { children: React.ReactNode }) {
const { isAuthenticated, isLoading } = useAuth();
if (isLoading) {
return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}>
<p>Laden...</p>
</div>
);
}
if (!isAuthenticated) {
return <Navigate to="/login" replace />;
}
return <>{children}</>;
}
export function App() {
return (
<Routes>
{/* Oeffentliche Routen */}
<Route path="/login" element={<LoginPage />} />
{/* Geschuetzte Routen */}
<Route
path="/"
element={
<PrivateRoute>
<AppLayout />
</PrivateRoute>
}
>
<Route index element={<DashboardPage />} />
<Route path="profile" element={<ProfilePage />} />
<Route path="admin/users" element={<AdminUsersPage />} />
<Route path="admin/tenants" element={<AdminTenantsPage />} />
</Route>
{/* Fallback */}
<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
);
}