All checks were successful
CI / Format (push) Successful in 42s
CI / CUDA type-check (push) Successful in 1m41s
CI / Clippy (push) Successful in 3m9s
CI / Test (push) Successful in 6m30s
CI / Build cortex SRPM (push) Has been skipped
CI / Build neuron SRPM (push) Has been skipped
CI / Publish cortex to COPR (push) Has been skipped
CI / Publish neuron to COPR (push) Has been skipped
CI / Bump version in source (push) Has been skipped
The self-service account surface consuming helexa-upstream's /web/v1 (B4/B5), with a mock so it works before/independent of the live backend. - api/types.ts + api/account.ts: typed AccountApi over a same-origin `/api` prefix (vite-proxied in dev, nginx in prod) covering register/verify/ login/password-reset/keys(list,create,archive,limit)/account/redeem; ApiError carries the backend code. MockAccountApi behind VITE_USE_MOCK_ACCOUNT_API (in-memory account, raw-key-once, redeem). - auth/: context + useAuth, AuthProvider (JWT in localStorage, login fetches the account and runs claimAnonymousData → anon IndexedDB history is re-owned to the account, still client-side), RequireAuth guard (→ /login?next=). - pages/auth/: Login, Register (sends the FingerprintJS visitor id → triggers the silent abuse detection), VerifyEmail (?token), RequestReset, ResetPassword (?token, matches the backend /reset?token= link). - pages/account/: Dashboard (allocation balance + usage bar, redeem top-up, logout) and ApiKeys (list, create-modal showing the raw key ONCE with copy, per-key limit editor percent↔hardcap, archive). 401 → logout. - App wraps AuthProvider + routes (account guarded); Header auth cluster reflects useAuth (Account/Sign out vs Sign in/up). - `account` i18n namespace (53 keys) added + wired across all 32 langs. Validated: lint, typecheck, build, i18n:check, lang-labels all green. Explicit-path commit; no node_modules/dist. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F6o3ddqmYNh9kzdwq6eowh
15 lines
545 B
TypeScript
15 lines
545 B
TypeScript
import { type ReactNode } from "react";
|
|
import { Navigate, useLocation } from "react-router-dom";
|
|
import { useAuth } from "./context";
|
|
|
|
/** Route guard: redirect unauthenticated users to /login?next=…. */
|
|
export default function RequireAuth({ children }: { children: ReactNode }) {
|
|
const { status } = useAuth();
|
|
const location = useLocation();
|
|
if (status !== "authed") {
|
|
const next = encodeURIComponent(location.pathname + location.search);
|
|
return <Navigate to={`/login?next=${next}`} replace />;
|
|
}
|
|
return <>{children}</>;
|
|
}
|