mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
feat: add ability to create an account via the webui (#223)
* feat: add ability to create an account via the webui without the need for autobrrctl * refactor redundant code block. * fix: early return and 0 value
This commit is contained in:
parent
982eddc269
commit
1a4f3cf55d
11 changed files with 337 additions and 109 deletions
|
@ -1,44 +1,49 @@
|
|||
import { Fragment } from "react";
|
||||
import { BrowserRouter as Router, Route } from "react-router-dom";
|
||||
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
|
||||
import { QueryClient, QueryClientProvider } from "react-query";
|
||||
import { ReactQueryDevtools } from "react-query/devtools";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
|
||||
import Base from "./screens/Base";
|
||||
import Login from "./screens/auth/login";
|
||||
import Logout from "./screens/auth/logout";
|
||||
import { Login } from "./screens/auth/login";
|
||||
import { Logout } from "./screens/auth/logout";
|
||||
import { Onboarding } from "./screens/auth/onboarding";
|
||||
import { baseUrl } from "./utils";
|
||||
|
||||
import { AuthContext, SettingsContext } from "./utils/Context";
|
||||
|
||||
function Protected() {
|
||||
return (
|
||||
<Fragment>
|
||||
<Toaster position="top-right" />
|
||||
<Base />
|
||||
</Fragment>
|
||||
)
|
||||
return (
|
||||
<Fragment>
|
||||
<Toaster position="top-right" />
|
||||
<Base />
|
||||
</Fragment>
|
||||
)
|
||||
}
|
||||
|
||||
export const queryClient = new QueryClient();
|
||||
|
||||
export function App() {
|
||||
const authContext = AuthContext.useValue();
|
||||
const settings = SettingsContext.useValue();
|
||||
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 ? (
|
||||
<ReactQueryDevtools initialIsOpen={false} />
|
||||
) : null}
|
||||
</QueryClientProvider>
|
||||
);
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<Router basename={baseUrl()}>
|
||||
<Route exact path="/logout" component={Logout} />
|
||||
|
||||
{authContext.isLoggedIn ? (
|
||||
<Route component={Protected} />
|
||||
) : (
|
||||
<Switch>
|
||||
<Route exact path="/onboard" component={Onboarding} />
|
||||
<Route component={Login} />
|
||||
</Switch>
|
||||
)}
|
||||
</Router>
|
||||
{settings.debug ? (
|
||||
<ReactQueryDevtools initialIsOpen={false} />
|
||||
) : null}
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue