Skip to content

Commit 16e9ca1

Browse files
fix(frontend): require session to show protected pages
1 parent a70ec9d commit 16e9ca1

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

frontend/src/layout/content/index.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
*/
88

99
import { Box, BoxProps, Grid, styled, Theme } from "@mui/material";
10+
import { useRouter } from "next/router";
1011
import { FC } from "react";
1112

13+
import { useAuth } from "@/hooks/useAuth";
1214
import { SXStyleOptions } from "@/utils/SXStyleOptions";
15+
import { hasPublicPath } from "@/utils/URL";
1316

1417
import { IContentPaddingProps } from "..";
1518

@@ -39,11 +42,20 @@ const DrawerHeader = styled("div")(({ theme }) => ({
3942
export type ContentProps = BoxProps & {
4043
children: JSX.Element;
4144
} & IContentPaddingProps;
42-
export const Content: FC<ContentProps> = ({ children, ...rest }) => (
43-
<StyledBox component="main" {...rest}>
44-
<Grid item xs>
45-
<DrawerHeader />
46-
</Grid>
47-
{children}
48-
</StyledBox>
49-
);
45+
export const Content: FC<ContentProps> = ({ children, ...rest }) => {
46+
const { pathname } = useRouter();
47+
const { isAuthenticated } = useAuth();
48+
49+
return (
50+
<StyledBox component="main" {...rest}>
51+
<Grid item xs>
52+
<DrawerHeader />
53+
</Grid>
54+
<Grid
55+
display={hasPublicPath(pathname) || isAuthenticated ? "block" : "none"}
56+
>
57+
{children}
58+
</Grid>
59+
</StyledBox>
60+
);
61+
};

0 commit comments

Comments
 (0)