Merge branch 'main' of https://github.com/john-david3/cs3305-team11
This commit is contained in:
@@ -42,7 +42,7 @@ function App() {
|
|||||||
|
|
||||||
<Route path="/:streamerName" element={<StreamerRoute />} />
|
<Route path="/:streamerName" element={<StreamerRoute />} />
|
||||||
<Route path="/user/:username" element={<UserPage />} />
|
<Route path="/user/:username" element={<UserPage />} />
|
||||||
<Route path="/reset_password" element={<ForgotPasswordPage />}></Route>
|
<Route path="/reset_password/:token" element={<ForgotPasswordPage />}></Route>
|
||||||
<Route path="/category/:category_name" element={<CategoryPage />}></Route>
|
<Route path="/category/:category_name" element={<CategoryPage />}></Route>
|
||||||
|
|
||||||
<Route path="*" element={<NotFoundPage />} />
|
<Route path="*" element={<NotFoundPage />} />
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ const PasswordResetForm: React.FC<SubmitProps> = ({ onSubmit, token }) => {
|
|||||||
newErrors[key as keyof ResetPasswordErrors] = "Confirm your password";
|
newErrors[key as keyof ResetPasswordErrors] = "Confirm your password";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (resetData.newPassword.length < 8) {
|
||||||
|
newErrors.newPasswordError = "Password must be at least 8 characters long";
|
||||||
|
}
|
||||||
if (resetData.newPassword !== resetData.confirmNewPassword) {
|
if (resetData.newPassword !== resetData.confirmNewPassword) {
|
||||||
newErrors.confirmNewPasswordError = "Passwords do not match";
|
newErrors.confirmNewPasswordError = "Passwords do not match";
|
||||||
}
|
}
|
||||||
@@ -64,7 +66,7 @@ const PasswordResetForm: React.FC<SubmitProps> = ({ onSubmit, token }) => {
|
|||||||
|
|
||||||
if (validateResetForm()) {
|
if (validateResetForm()) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch("/user/reset_password/<string:${token}", {
|
const response = await fetch(`/user/reset_password/${token}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -76,6 +78,8 @@ const PasswordResetForm: React.FC<SubmitProps> = ({ onSubmit, token }) => {
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
throw new Error(data.message || "An error has occurred while resetting");
|
throw new Error(data.message || "An error has occurred while resetting");
|
||||||
|
} else {
|
||||||
|
confirmPasswordReset();
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("Password reset error:", error.message);
|
console.error("Password reset error:", error.message);
|
||||||
@@ -84,7 +88,6 @@ const PasswordResetForm: React.FC<SubmitProps> = ({ onSubmit, token }) => {
|
|||||||
general: error.message || "An unexpected error occurred.",
|
general: error.message || "An unexpected error occurred.",
|
||||||
|
|
||||||
}));
|
}));
|
||||||
confirmPasswordReset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user