RC-4: add authService sendPasswordResetEmail method to forgot password page
This commit is contained in:
@@ -7,6 +7,7 @@ import Typography from '@mui/material/Typography';
|
|||||||
import { Controller, useForm } from 'react-hook-form';
|
import { Controller, useForm } from 'react-hook-form';
|
||||||
import { withTranslation } from 'react-i18next';
|
import { withTranslation } from 'react-i18next';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import { authService } from 'src/app/services';
|
||||||
import * as yup from 'yup';
|
import * as yup from 'yup';
|
||||||
import LeftSideCanvas from '../shared-components/LeftSideCanvas';
|
import LeftSideCanvas from '../shared-components/LeftSideCanvas';
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ function ForgotPasswordPage({ t }) {
|
|||||||
email: yup.string().email(t('email_error')).required(t('email_error')),
|
email: yup.string().email(t('email_error')).required(t('email_error')),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { control, formState, handleSubmit, reset } = useForm({
|
const { control, formState, handleSubmit, setError } = useForm({
|
||||||
mode: 'onChange',
|
mode: 'onChange',
|
||||||
defaultValues,
|
defaultValues,
|
||||||
resolver: yupResolver(schema),
|
resolver: yupResolver(schema),
|
||||||
@@ -27,8 +28,13 @@ function ForgotPasswordPage({ t }) {
|
|||||||
|
|
||||||
const { isValid, dirtyFields, errors } = formState;
|
const { isValid, dirtyFields, errors } = formState;
|
||||||
|
|
||||||
function onSubmit() {
|
function onSubmit({ email }) {
|
||||||
reset(defaultValues);
|
authService.sendPasswordResetEmail(email).catch((error) => {
|
||||||
|
setError('root', {
|
||||||
|
type: 'manual',
|
||||||
|
message: error.message,
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user