Skip to content

Commit

Permalink
feat: block access to not logged in users (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette authored Dec 4, 2022
1 parent 5db8726 commit d51074d
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 8 deletions.
82 changes: 74 additions & 8 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Home,
Nutrition,
FlaggedImages,
ShouldLoggedinPage,
PackagingPage,
} from "./pages";
import ResponsiveAppBar from "./components/ResponsiveAppBar";
Expand Down Expand Up @@ -168,26 +169,91 @@ export default function App() {
<Routes>
<Route path="/" element={<Home />} />
<Route path="/eco-score" element={<EcoScorePage />} />
<Route path="/logos" element={<LogoAnnotationPage />} />
<Route path="/logos/search" element={<LogoSearchPage />} />
<Route path="/logos/:logoId" element={<LogoUpdatePage />} />
<Route
path="/logos"
element={
userState.isLoggedIn ? (
<LogoAnnotationPage />
) : (
<ShouldLoggedinPage />
)
}
/>
<Route
path="/logos/search"
element={
userState.isLoggedIn ? (
<LogoSearchPage />
) : (
<ShouldLoggedinPage />
)
}
/>
<Route
path="/logos/:logoId"
element={
userState.isLoggedIn ? (
<LogoUpdatePage />
) : (
<ShouldLoggedinPage />
)
}
/>
<Route
path="/logos/product-search"
element={<ProductLogoAnnotationPage />}
element={
userState.isLoggedIn ? (
<ProductLogoAnnotationPage />
) : (
<ShouldLoggedinPage />
)
}
/>
<Route
path="/logos/deep-search"
element={
userState.isLoggedIn ? (
<LogoDeepSearch />
) : (
<ShouldLoggedinPage />
)
}
/>
<Route path="/logos/deep-search" element={<LogoDeepSearch />} />

<Route path="/settings" element={<SettingsPage />} />
<Route path="/questions" element={<QuestionsPage />} />
<Route path="/insights" element={<InsightsPage />} />
<Route path="*" element={<NotFoundPage />} />
<Route path="/nutriscore" element={<NutriscoreValidator />} />
<Route path="/nutrition" element={<Nutrition />} />
<Route
path="/nutriscore"
element={
userState.isLoggedIn ? (
<NutriscoreValidator />
) : (
<ShouldLoggedinPage />
)
}
/>
<Route
path="/nutrition"
element={
userState.isLoggedIn ? <Nutrition /> : <ShouldLoggedinPage />
}
/>
{showFlaggedImage && (
<Route path="/flagged-images" element={<FlaggedImages />} />
)}

<Route path="/packaging" element={<PackagingPage />} />
<Route
path="/packaging"
element={
userState.isLoggedIn ? (
<PackagingPage />
) : (
<ShouldLoggedinPage />
)
}
/>
</Routes>
</DevModeContext.Provider>
</LoginContext.Provider>
Expand Down
1 change: 1 addition & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export { default as LogoDeepSearch } from "./logos/LogoDeepSearch";
export { default as NutriscoreValidator } from "./nutriscoreValidator";
export { default as FlaggedImages } from "./flaggedImages";

export { default as ShouldLoggedinPage } from "./shouldLoggedinPage";
export { default as PackagingPage } from "./packaging";
12 changes: 12 additions & 0 deletions src/pages/shouldLoggedinPage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";

const ShouldLoggedinPage = () => (
<Box sx={{ p: 2 }}>
<Typography variant="h5" component="h1" sx={{ mb: 2 }}>
Restricted page
</Typography>
<Typography>Advenced game are restricted to connected user</Typography>
</Box>
);
export default ShouldLoggedinPage;

0 comments on commit d51074d

Please sign in to comment.