Files
Cosmos-Server/client/src/PrivateRoute.jsx
Kawanaao 87c1636ff7 [skip ci] Optimizations/react (#186)
* Replaced the lodash module with submodules

* Using lazy imports of heavy modules

* Replaced the old authorization verification system with PrivateRoute

* Dynamic import of all paths

* Minifying the syntax highlighting library

* Added missing imports

* Added expires to head meta

* Don't force the code to follow unnecessary redirects

* Kawanaao accept CLA

---------

Co-authored-by: Yann S <7872597+azukaar@users.noreply.github.com>
2024-02-04 12:43:27 +00:00

19 lines
442 B
JavaScript

import { Suspense } from "react"
import { Await, Navigate } from "react-router"
import isLoggedIn from "./isLoggedIn"
function PrivateRoute({ children }) {
return <Suspense>
<Await resolve={isLoggedIn()}>
{authStatus => {
switch (authStatus) {
case "OK": return children
default: return <Navigate to={authStatus} replace />
}
}}
</Await>
</Suspense>
}
export default PrivateRoute