mirror of
https://github.com/azukaar/Cosmos-Server.git
synced 2026-01-24 05:28:51 -06:00
* 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>
19 lines
442 B
JavaScript
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
|