Files
refboard-ayon/frontend/src/App.tsx
T
Hermes 5a4cfcbf64 feat: AYON single-sign-on (ticket exchange, task boards, browser entry)
- POST /api/auth/ayon/exchange: redeem single-use ticket (issued by the
  AYON addon) via AYON_EXCHANGE_URL, mint session JWT, get-or-create
  internal user row and the <project>/<task> board in the AYON collection
- db: getOrCreateAyonUser / getOrCreateAyonBoard / grantAyonCollectionAccess
- frontend: /b route redeems ticket from URL and forwards to the board
- password login/register paths untouched (legacy instance support)
2026-09-04 13:40:33 +00:00

56 lines
1.7 KiB
TypeScript

import React from 'react';
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import { AuthProvider, useAuth } from './auth';
import Login from './pages/Login';
import CollectionList from './pages/CollectionList';
import CollectionDetail from './pages/CollectionDetail';
import Editor from './pages/Editor';
import Admin from './pages/Admin';
import AyonEntry from './pages/AyonEntry';
function ProtectedRoute({ children }: { children: React.ReactNode }) {
const { user, loading } = useAuth();
if (loading) {
return (
<div style={{
display: 'flex', alignItems: 'center', justifyContent: 'center',
height: '100vh', background: '#1a1a1a', color: '#e0e0e0', fontSize: '18px',
}}>
Loading...
</div>
);
}
if (!user) {
return <Navigate to="/login" replace />;
}
return <>{children}</>;
}
function AppRoutes() {
return (
<Routes>
<Route path="/login" element={<Login />} />
<Route path="/b" element={<AyonEntry />} />
<Route path="/" element={<ProtectedRoute><CollectionList /></ProtectedRoute>} />
<Route path="/collection/:collectionId" element={<ProtectedRoute><CollectionDetail /></ProtectedRoute>} />
<Route path="/board/:boardId" element={<ProtectedRoute><Editor /></ProtectedRoute>} />
<Route path="/admin" element={<ProtectedRoute><Admin /></ProtectedRoute>} />
<Route path="/c/:shareToken" element={<CollectionDetail isPublicView />} />
<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
);
}
export default function App() {
return (
<BrowserRouter>
<AuthProvider>
<AppRoutes />
</AuthProvider>
</BrowserRouter>
);
}