mirror of
https://github.com/idanoo/autobrr
synced 2025-07-25 17:59:14 +00:00
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:
parent
baac92cc25
commit
2d3ab67604
4 changed files with 25 additions and 11 deletions
|
@ -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 ? (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue