zot-wo-auth/zui-auth.patch

64 lines
2.3 KiB
Diff
Raw Normal View History

2024-04-26 13:41:11 +03:00
diff --git a/src/App.js b/src/App.js
2024-04-26 13:41:40 +03:00
index 6fdd96c..0ac0e05 100644
2024-04-26 13:41:11 +03:00
--- a/src/App.js
+++ b/src/App.js
2024-04-26 13:41:40 +03:00
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
2024-04-26 13:41:11 +03:00
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
2024-04-26 13:41:40 +03:00
import { isAuthenticated, isApiKeyEnabled } from 'utilities/authUtilities';
2024-04-26 13:41:11 +03:00
-import { AuthWrapper } from 'utilities/AuthWrapper';
2024-04-26 13:41:40 +03:00
+import { NoAuthWrapper } from 'utilities/NoAuthWrapper';
2024-04-26 13:41:11 +03:00
import HomePage from './pages/HomePage';
import LoginPage from './pages/LoginPage';
2024-04-26 13:41:40 +03:00
@@ -20,18 +20,15 @@ function App() {
2024-04-26 13:41:11 +03:00
<div className="App" data-testid="app-container">
<Router>
<Routes>
- <Route element={<AuthWrapper isLoggedIn={isLoggedIn} hasHeader redirect="/login" />}>
2024-04-26 13:41:40 +03:00
+ <Route element={<NoAuthWrapper hasHeader />}>
<Route path="/" element={<Navigate to="/home" />} />
<Route path="/home" element={<HomePage />} />
<Route path="/explore" element={<ExplorePage />} />
<Route path="/image/:name" element={<RepoPage />} />
<Route path="/image/:reponame/tag/:tag" element={<TagPage />} />
{isApiKeyEnabled() && <Route path="/user/apikey" element={<UserManagementPage />} />}
2024-04-26 13:41:11 +03:00
- <Route path="*" element={<Navigate to="/home" />} />
- </Route>
- <Route element={<AuthWrapper isLoggedIn={!isLoggedIn} redirect="/" />}>
2024-04-26 13:41:40 +03:00
<Route path="/login" element={<LoginPage isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} />} />
2024-04-26 13:41:11 +03:00
- <Route path="*" element={<Navigate to="/login" />} />
2024-04-26 13:41:40 +03:00
+ <Route path="*" element={<Navigate to="/home" />} />
</Route>
2024-04-26 13:41:11 +03:00
</Routes>
</Router>
2024-04-26 13:41:40 +03:00
diff --git a/src/utilities/NoAuthWrapper.jsx b/src/utilities/NoAuthWrapper.jsx
new file mode 100644
index 0000000..974e11f
--- /dev/null
+++ b/src/utilities/NoAuthWrapper.jsx
@@ -0,0 +1,23 @@
+import React from 'react';
+import { Outlet } from 'react-router-dom';
+import makeStyles from '@mui/styles/makeStyles';
+
+const useStyles = makeStyles(() => ({
+ topMargin: {
+ marginTop: '10vh',
+ minHeight: '90vh',
+ height: '100%'
+ }
+}));
+
+const NoAuthWrapper = ({ hasHeader = false }) => {
+ const classes = useStyles();
+
+ return (
+ <div className={hasHeader ? classes.topMargin : null}>
+ <Outlet />
+ </div>
+ );
+};
+
+export { NoAuthWrapper };