feat(web): redirect to login on expired cookie (#201)

* feat(web): redirect to login on expired cookie

* refactor: simplify auth wrapper
This commit is contained in:
Ludvig Lundgren 2022-03-26 19:46:16 +01:00 committed by GitHub
parent baac92cc25
commit 2d3ab67604
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 11 deletions

View file

@ -1,5 +1,6 @@
import { QueryClient, QueryClientProvider } from "react-query";
import { Fragment } from "react";
import { BrowserRouter as Router, Route } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
import { Toaster } from "react-hot-toast";
@ -12,10 +13,10 @@ import { AuthContext, SettingsContext } from "./utils/Context";
function Protected() {
return (
<>
<Fragment>
<Toaster position="top-right" />
<Base />
</>
</Fragment>
)
}
@ -24,14 +25,15 @@ export const queryClient = new QueryClient();
export function App() {
const authContext = AuthContext.useValue();
const settings = SettingsContext.useValue();
return (
<QueryClientProvider client={queryClient}>
<Router basename={baseUrl()}>
{authContext.isLoggedIn ? (
<Route exact path="/*" component={Protected} />
) : (
) :
<Route exact path="/*" component={Login} />
)}
}
<Route exact path="/logout" component={Logout} />
</Router>
{settings.debug ? (