From b8984c01603aeae8171a2416cf2abd2bd87087ea Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 27 Sep 2024 13:38:57 +0800 Subject: [PATCH] Restrict access to advanced settings page --- Client/src/Pages/AdvancedSettings/index.jsx | 12 ++++--- Client/src/Pages/Settings/index.jsx | 38 +++++++++++---------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Client/src/Pages/AdvancedSettings/index.jsx b/Client/src/Pages/AdvancedSettings/index.jsx index 59e677138..29a9fe53c 100644 --- a/Client/src/Pages/AdvancedSettings/index.jsx +++ b/Client/src/Pages/AdvancedSettings/index.jsx @@ -10,14 +10,17 @@ import LoadingButton from "@mui/lab/LoadingButton"; import { ConfigBox } from "../Settings/styled"; import { useNavigate } from "react-router"; import { updateAppSettings } from "../../Features/Settings/settingsSlice"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import Select from "../../Components/Inputs/Select"; const AdvancedSettings = ({ isAdmin }) => { const navigate = useNavigate(); - if (!isAdmin) { - navigate("/"); - } + + useEffect(() => { + if (!isAdmin) { + navigate("/"); + } + }, [navigate, isAdmin]); const theme = useTheme(); const { authToken } = useSelector((state) => state.auth); @@ -75,7 +78,6 @@ const AdvancedSettings = ({ isAdmin }) => { noValidate spellCheck="false" > - \{" "} Client Settings diff --git a/Client/src/Pages/Settings/index.jsx b/Client/src/Pages/Settings/index.jsx index 63199f9f4..bf8cfcc79 100644 --- a/Client/src/Pages/Settings/index.jsx +++ b/Client/src/Pages/Settings/index.jsx @@ -251,26 +251,28 @@ const Settings = ({ isAdmin }) => { )} - - - Advanced Settings - - Click here to modify advanced settings - - - + {isAdmin && ( + - + Advanced Settings + + Click here to modify advanced settings + - - + + + + + + + )} About