Skip to content

Commit

Permalink
fix: give access to moderator only
Browse files Browse the repository at this point in the history
  • Loading branch information
Valimp committed Mar 8, 2024
1 parent 4519bec commit a92b950
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import LayoutMenu from "../components/Layouts/LayoutMenu.tsx";
import LoginContext from "./contexts/login.tsx";
import NotFound from "../pages/NotFound.tsx";

const MODERATORS = [
"valimp",
"alex-off",
]

export default function App() {

// turn in to true to test the moderation page - it will always be logged in
Expand Down Expand Up @@ -88,12 +93,14 @@ export default function App() {
refresh();
}, [refresh]);

const showTickets = MODERATORS.includes(userState.userName);

return (
<LoginContext.Provider value={{ ...userState, refresh }}>
<LayoutMenu>
<Routes>
<Route path="/" element={<HomePage />} />
<Route path="/moderation" element={userState.isLoggedIn ? < ModerationPage/> : <LoginPage />} />
<Route path="/moderation" element={userState.isLoggedIn && showTickets ? < ModerationPage/> : <LoginPage />} />
<Route path="/login" element={<LoginPage />} />
<Route path="*" element={<NotFound />} />
</Routes>
Expand Down

0 comments on commit a92b950

Please sign in to comment.