diff --git a/src/App.jsx b/src/App.jsx
index 4ab6b92d..8a43ced8 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -58,6 +58,7 @@ function MainContent() {
const { setUserData, loading } = useContext(GlobalDataContext);
const navigate = useNavigate();
+ const location = useLocation();
// eslint-disable-next-line no-unused-vars
const [existingCookies, setCookie, removeCookie] = useCookies(['session']);
@@ -75,7 +76,10 @@ function MainContent() {
groupname: userData['groupname'],
settings: userData
});
- navigate("/");
+ // Only redirect to home if user is currently on login/register pages
+ if (location.pathname === '/login' || location.pathname === '/register') {
+ navigate("/");
+ }
} catch (error) {
console.error("Error fetching user settings:", error);
localStorage.removeItem(API_CONFIG.SESSION_DATA.SETTINGS);
@@ -89,7 +93,7 @@ function MainContent() {
}
})();
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
+ }, [location.pathname]);
if (loading) {
return (
diff --git a/src/components/Auth/ForgotPassword.jsx b/src/components/Auth/ForgotPassword.jsx
index 7c1662ea..a72d8d5a 100644
--- a/src/components/Auth/ForgotPassword.jsx
+++ b/src/components/Auth/ForgotPassword.jsx
@@ -1,7 +1,7 @@
import * as React from "react";
import { Box, Button, FormControl, Grid, Paper, Typography } from "@mui/material";
import { ArrowBack } from "@mui/icons-material";
-import FormField from "./UI/Formfield";
+import CustomFormField from "../common/CustomFormField";
import { Link } from "react-router-dom";
import { forgotPassword } from "../../api/endpoints/apiService";
@@ -11,7 +11,7 @@ const ForgotPassword = () => {
const handleForgotPassword = async () => {
try {
- await forgotPassword({username: username});
+ await forgotPassword({ username: username });
} catch (error) {
console.error("Error:", error);
setError(error.message);
@@ -29,13 +29,15 @@ const ForgotPassword = () => {