Feat(Fix): SSH Keys-Expiry+Log; Department+Principal Link; CA Keys mgmt;
- Fix Login nav to /profile or /
This commit is contained in:
+19
-2
@@ -19,12 +19,14 @@ import InviteAcceptPage from "@/pages/auth/InviteAcceptPage";
|
||||
import OIDCConsentPage from "@/pages/auth/OIDCConsentPage";
|
||||
import OIDCErrorPage from "@/pages/auth/OIDCErrorPage";
|
||||
import OAuthCallbackPage from "@/pages/auth/OAuthCallbackPage";
|
||||
import ActivatePage from "@/pages/auth/ActivatePage";
|
||||
|
||||
// User pages
|
||||
import ProfilePage from "@/pages/user/ProfilePage";
|
||||
import SecurityPage from "@/pages/user/SecurityPage";
|
||||
import LinkedAccountsPage from "@/pages/user/LinkedAccountsPage";
|
||||
import ActivityPage from "@/pages/user/ActivityPage";
|
||||
import SSHKeysPage from "@/pages/user/SSHKeysPage";
|
||||
|
||||
// Organization pages
|
||||
import OrgOverviewPage from "@/pages/org/OrgOverviewPage";
|
||||
@@ -33,9 +35,11 @@ import PoliciesPage from "@/pages/org/PoliciesPage";
|
||||
import CompliancePage from "@/pages/org/CompliancePage";
|
||||
import OrgAuditPage from "@/pages/org/OrgAuditPage";
|
||||
import OIDCClientsPage from "@/pages/org/OIDCClientsPage";
|
||||
import CAsPage from "@/pages/org/CAsPage";
|
||||
import DepartmentsPage from "@/pages/org/DepartmentsPage";
|
||||
import PrincipalsPage from "@/pages/org/PrincipalsPage";
|
||||
import SystemAuditPage from "@/pages/admin/SystemAuditPage";
|
||||
import AdminUsersPage from "@/pages/admin/AdminUsersPage";
|
||||
|
||||
import NotFound from "@/pages/NotFound";
|
||||
import ApiDevTools from "@/components/dev/ApiDevTools";
|
||||
@@ -68,7 +72,16 @@ const App = () => (
|
||||
);
|
||||
|
||||
// Separate component so AuthProvider can use useNavigate
|
||||
import { AuthProvider } from "@/contexts/AuthContext";
|
||||
import { AuthProvider, useAuth } from "@/contexts/AuthContext";
|
||||
import { Navigate } from "react-router-dom";
|
||||
|
||||
/** Redirects already-authenticated users away from guest-only pages (e.g. /login). */
|
||||
function GuestRoute({ children }: { children: React.ReactNode }) {
|
||||
const { isAuthenticated, isLoading } = useAuth();
|
||||
if (isLoading) return null; // wait for auth state to resolve
|
||||
if (isAuthenticated) return <Navigate to="/profile" replace />;
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
function AppRoutes() {
|
||||
return (
|
||||
@@ -79,7 +92,7 @@ function AppRoutes() {
|
||||
|
||||
{/* Public routes */}
|
||||
<Route element={<PublicLayout />}>
|
||||
<Route path="/login" element={<LoginPage />} />
|
||||
<Route path="/login" element={<GuestRoute><LoginPage /></GuestRoute>} />
|
||||
<Route path="/register" element={<RegisterPage />} />
|
||||
<Route path="/verify-email" element={<VerifyEmailPage />} />
|
||||
<Route path="/forgot-password" element={<ForgotPasswordPage />} />
|
||||
@@ -88,6 +101,7 @@ function AppRoutes() {
|
||||
<Route path="/consent" element={<OIDCConsentPage />} />
|
||||
<Route path="/error" element={<OIDCErrorPage />} />
|
||||
<Route path="/oauth/callback" element={<OAuthCallbackPage />} />
|
||||
<Route path="/activate" element={<ActivatePage />} />
|
||||
</Route>
|
||||
|
||||
{/* Protected routes - handles auth and MFA enforcement */}
|
||||
@@ -97,6 +111,7 @@ function AppRoutes() {
|
||||
<Route path="/security" element={<SecurityPage />} />
|
||||
<Route path="/linked-accounts" element={<LinkedAccountsPage />} />
|
||||
<Route path="/activity" element={<ActivityPage />} />
|
||||
<Route path="/ssh-keys" element={<SSHKeysPage />} />
|
||||
|
||||
{/* Organization routes */}
|
||||
<Route path="/org" element={<OrgOverviewPage />} />
|
||||
@@ -107,9 +122,11 @@ function AppRoutes() {
|
||||
<Route path="/org/policies/compliance" element={<CompliancePage />} />
|
||||
<Route path="/org/audit" element={<OrgAuditPage />} />
|
||||
<Route path="/org/clients" element={<OIDCClientsPage />} />
|
||||
<Route path="/org/cas" element={<CAsPage />} />
|
||||
|
||||
{/* Admin routes */}
|
||||
<Route path="/admin/audit" element={<SystemAuditPage />} />
|
||||
<Route path="/admin/users" element={<AdminUsersPage />} />
|
||||
</Route>
|
||||
|
||||
{/* Catch-all */}
|
||||
|
||||
Reference in New Issue
Block a user