feat: implement tenant OAuth flow and guest achievements
This commit is contained in:
@@ -1,20 +1,36 @@
|
||||
import React from 'react';
|
||||
import { createBrowserRouter, Outlet, Navigate } from 'react-router-dom';
|
||||
import { createBrowserRouter, Outlet, Navigate, useLocation } from 'react-router-dom';
|
||||
import LoginPage from './pages/LoginPage';
|
||||
import EventsPage from './pages/EventsPage';
|
||||
import SettingsPage from './pages/SettingsPage';
|
||||
import EventFormPage from './pages/EventFormPage';
|
||||
import EventPhotosPage from './pages/EventPhotosPage';
|
||||
import EventDetailPage from './pages/EventDetailPage';
|
||||
import AuthCallbackPage from './pages/AuthCallbackPage';
|
||||
import { useAuth } from './auth/context';
|
||||
|
||||
function RequireAuth() {
|
||||
const token = localStorage.getItem('ta_token');
|
||||
if (!token) return <Navigate to="/admin/login" replace />;
|
||||
const { status } = useAuth();
|
||||
const location = useLocation();
|
||||
|
||||
if (status === 'loading') {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center text-sm text-muted-foreground">
|
||||
Bitte warten <EFBFBD>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (status === 'unauthenticated') {
|
||||
return <Navigate to="/admin/login" state={{ from: location }} replace />;
|
||||
}
|
||||
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
export const router = createBrowserRouter([
|
||||
{ path: '/admin/login', element: <LoginPage /> },
|
||||
{ path: '/admin/auth/callback', element: <AuthCallbackPage /> },
|
||||
{
|
||||
path: '/admin',
|
||||
element: <RequireAuth />,
|
||||
|
||||
Reference in New Issue
Block a user