Harden auth and improve user management
This commit is contained in:
@@ -12,9 +12,14 @@ import PortalPage from "./pages/PortalPage";
|
||||
import SearchPage from "./pages/SearchPage";
|
||||
import SearchFarmerPage from "./pages/SearchFarmerPage";
|
||||
import SearchCalendarPage from "./pages/SearchCalendarPage";
|
||||
import UserManagementPage from "./pages/UserManagementPage";
|
||||
|
||||
function ProtectedRoutes() {
|
||||
const { user } = useSession();
|
||||
const { user, ready } = useSession();
|
||||
|
||||
if (!ready) {
|
||||
return <div className="empty-state">Sitzung wird geladen ...</div>;
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
return <Navigate to="/" replace />;
|
||||
@@ -30,6 +35,7 @@ function ProtectedRoutes() {
|
||||
<Route path="/samples/:sampleId/antibiogram" element={<AntibiogramPage />} />
|
||||
<Route path="/samples/:sampleId/therapy" element={<TherapyPage />} />
|
||||
<Route path="/admin" element={<Navigate to="/admin/landwirte" replace />} />
|
||||
<Route path="/admin/benutzer" element={<UserManagementPage />} />
|
||||
<Route path="/admin/landwirte" element={<AdministrationPage />} />
|
||||
<Route path="/admin/medikamente" element={<AdministrationPage />} />
|
||||
<Route path="/admin/erreger" element={<AdministrationPage />} />
|
||||
@@ -46,7 +52,10 @@ function ProtectedRoutes() {
|
||||
}
|
||||
|
||||
function ApplicationRouter() {
|
||||
const { user } = useSession();
|
||||
const { user, ready } = useSession();
|
||||
if (!ready) {
|
||||
return <div className="empty-state">Sitzung wird geladen ...</div>;
|
||||
}
|
||||
if (!user) {
|
||||
return (
|
||||
<Routes>
|
||||
|
||||
Reference in New Issue
Block a user