From 1d4763333bdcf91f6c30cea246730479b3e235e9 Mon Sep 17 00:00:00 2001
From: Mikayla Dobson <93477693+innocuous-symmetry@users.noreply.github.com>
Date: Sat, 18 Feb 2023 11:05:48 -0600
Subject: [PATCH] oops nevermind LOL
---
client/src/util/Protect.tsx | 48 ++++++++++++++++++-------------------
client/src/util/types.ts | 2 +-
2 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/client/src/util/Protect.tsx b/client/src/util/Protect.tsx
index edc7b9a..3e5c506 100644
--- a/client/src/util/Protect.tsx
+++ b/client/src/util/Protect.tsx
@@ -7,41 +7,39 @@ import API from "./API";
import { ProtectPortal } from "./types";
const Protect: ProtectPortal = ({ children, redirect = '', accessRules = null }) => {
- const [view, setView] = useState(Loading...
);
const { user, token } = useAuthContext();
const navigate = useNavigate();
- useEffect(() => {
- if (!user || !token) {
- setView(
+ if (!user || !token) {
+ return (
+
+ <>
+ Hi there! You don't look too familiar.
+ To view the content on this page, please log in below:
+
+ >
+
+ )
+ }
+
+ if (accessRules !== null) {
+ if (accessRules.mustBeRecipinAdmin && !(user?.isadmin)) {
+ return (
<>
- Hi there! You don't look too familiar.
- To view the content on this page, please log in below:
-
+ This page requires administrator access.
+ If you believe you are receiving this message in error, please contact Recipin support.
>
)
-
- return;
}
-
- if (accessRules !== null) {
- if (accessRules.mustBeRecipinAdmin && !(user.isadmin)) {
- setView(
-
- <>
- This page requires administrator access.
- If you believe you are receiving this message in error, please contact Recipin support.
- >
-
- )
- }
- }
- }, [user, token])
+ }
-
- return view;
+ return (
+
+ { children }
+
+ )
}
export default Protect;
\ No newline at end of file
diff --git a/client/src/util/types.ts b/client/src/util/types.ts
index fd5ba5d..152b119 100644
--- a/client/src/util/types.ts
+++ b/client/src/util/types.ts
@@ -23,7 +23,7 @@ export interface AccessRules {
export interface ProtectParams extends PortalBase {
redirect?: string
- accessRules?: AccessRules | null
+ accessRules?: Partial | null
}
interface UserCardProps extends PortalBase {