UPDATE: Now checks for token on url to extract.

This commit is contained in:
EvanLin3141
2025-02-06 15:44:20 +00:00
parent af71f63873
commit 00d627a1e2
2 changed files with 34 additions and 11 deletions

View File

@@ -15,9 +15,10 @@ interface ResetPasswordErrors {
interface SubmitProps {
onSubmit: () => void;
token: string;
}
const PasswordResetForm: React.FC<SubmitProps> = ({ onSubmit }) => {
const PasswordResetForm: React.FC<SubmitProps> = ({ onSubmit, token }) => {
const [errors, setErrors] = useState<ResetPasswordErrors>({});
@@ -63,7 +64,7 @@ const PasswordResetForm: React.FC<SubmitProps> = ({ onSubmit }) => {
if (validateResetForm()) {
try {
const response = await fetch("/user/reset_password/<string:token>/<string:confirmNewPassword>", {
const response = await fetch("/user/reset_password/<string:${token}", {
method: "POST",
headers: {
"Content-Type": "application/json",

View File

@@ -1,15 +1,37 @@
import React from 'react';
import PasswordResetForm from '../components/Auth/PasswordResetForm';
import React from "react";
import PasswordResetForm from "../components/Auth/PasswordResetForm";
import { useParams, useNavigate } from "react-router-dom";
const ForgotPasswordPage: React.FC = () => {
const doNothing = (): void => {};
const { token } = useParams<{ token: string }>();
const navigate = useNavigate();
return (
<div className="flex flex-col items-center justify-center h-screen">
<h1 className="text-2xl font-bold mb-4">Forgot Password</h1>
<PasswordResetForm onSubmit={doNothing} />
</div>
);
// If the token is missing, handle the error (e.g., redirect or show a message)
if (!token) {
return (
<div className="flex flex-col items-center justify-center h-screen">
<h1 className="text-2xl font-bold mb-4">Invalid Token</h1>
<p className="text-red-500">The reset token is missing or invalid.</p>
<button
onClick={() => navigate("/login")}
className="text-blue-500 underline mt-4"
>
Go back to Login
</button>
</div>
);
}
const handlePasswordReset = () => {
};
return (
<div className="flex flex-col items-center justify-center h-screen">
<h1 className="text-2xl font-bold mb-4">Forgot Password</h1>
<PasswordResetForm onSubmit={handlePasswordReset} token={token} />
</div>
);
};
export default ForgotPasswordPage;