From 00d627a1e2c9a52c62a9f93ab9041be87106024c Mon Sep 17 00:00:00 2001 From: EvanLin3141 Date: Thu, 6 Feb 2025 15:44:20 +0000 Subject: [PATCH] UPDATE: Now checks for token on url to extract. --- .../src/components/Auth/PasswordResetForm.tsx | 5 ++- frontend/src/pages/ForgotPasswordPage.tsx | 40 ++++++++++++++----- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/Auth/PasswordResetForm.tsx b/frontend/src/components/Auth/PasswordResetForm.tsx index 39c9d42..9931abc 100644 --- a/frontend/src/components/Auth/PasswordResetForm.tsx +++ b/frontend/src/components/Auth/PasswordResetForm.tsx @@ -15,9 +15,10 @@ interface ResetPasswordErrors { interface SubmitProps { onSubmit: () => void; + token: string; } -const PasswordResetForm: React.FC = ({ onSubmit }) => { +const PasswordResetForm: React.FC = ({ onSubmit, token }) => { const [errors, setErrors] = useState({}); @@ -63,7 +64,7 @@ const PasswordResetForm: React.FC = ({ onSubmit }) => { if (validateResetForm()) { try { - const response = await fetch("/user/reset_password//", { + const response = await fetch("/user/reset_password/ { - const doNothing = (): void => {}; + const { token } = useParams<{ token: string }>(); + const navigate = useNavigate(); - return ( -
-

Forgot Password

- -
- ); + // If the token is missing, handle the error (e.g., redirect or show a message) + if (!token) { + return ( +
+

Invalid Token

+

The reset token is missing or invalid.

+ +
+ ); + } + + const handlePasswordReset = () => { + + }; + + return ( +
+

Forgot Password

+ +
+ ); }; export default ForgotPasswordPage;