UPDATE: Now checks for token on url to extract.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -1,13 +1,35 @@
|
||||
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();
|
||||
|
||||
// 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={doNothing} />
|
||||
<PasswordResetForm onSubmit={handlePasswordReset} token={token} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user