fix: reset password page not having captcha

This commit is contained in:
Naterfute
2025-08-11 22:48:59 -07:00
parent 3ae9115ea3
commit 670aa79906

View File

@@ -1,6 +1,6 @@
import { Actions, useStoreActions } from 'easy-peasy'; import { Actions, useStoreActions } from 'easy-peasy';
import { Formik, FormikHelpers } from 'formik'; import { Formik, FormikHelpers } from 'formik';
import { useState } from 'react'; import { useEffect, useState } from 'react';
import { Link, useParams } from 'react-router-dom'; import { Link, useParams } from 'react-router-dom';
import { object, ref, string } from 'yup'; import { object, ref, string } from 'yup';
@@ -18,6 +18,8 @@ import { httpErrorToHuman } from '@/api/http';
import { ApplicationStore } from '@/state'; import { ApplicationStore } from '@/state';
import useFlash from '@/plugins/useFlash';
import Logo from '../elements/PyroLogo'; import Logo from '../elements/PyroLogo';
interface Values { interface Values {
@@ -28,7 +30,11 @@ interface Values {
function ResetPasswordContainer() { function ResetPasswordContainer() {
const [email, setEmail] = useState(''); const [email, setEmail] = useState('');
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes); const { clearFlashes, clearAndAddHttpError } = useFlash();
useEffect(() => {
clearFlashes();
}, []);
const parsed = new URLSearchParams(location.search); const parsed = new URLSearchParams(location.search);
if (email.length === 0 && parsed.get('email')) { if (email.length === 0 && parsed.get('email')) {
@@ -60,7 +66,9 @@ function ResetPasswordContainer() {
console.error(error); console.error(error);
setSubmitting(false); setSubmitting(false);
addFlash({ type: 'error', title: 'Error', message: httpErrorToHuman(error) }); clearAndAddHttpError({
error: new Error(error),
});
}); });
}; };
@@ -111,6 +119,16 @@ function ResetPasswordContainer() {
type={'password'} type={'password'}
/> />
</div> </div>
<Captcha
className='mt-6'
onError={(error) => {
console.error('Captcha error:', error);
clearAndAddHttpError({
error: new Error('Captcha verification failed. Please try again.'),
});
}}
/>
<div className={`mt-6`}> <div className={`mt-6`}>
<Button <Button
className='w-full mt-4 rounded-full bg-brand border-0 ring-0 outline-hidden capitalize font-bold text-sm py-2' className='w-full mt-4 rounded-full bg-brand border-0 ring-0 outline-hidden capitalize font-bold text-sm py-2'