From cbbe5b6fa9cd363788c21038b2b02217f0413355 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 17 Oct 2020 14:45:33 -0700 Subject: [PATCH] Reset error messages between login screens; ref #2455 --- .../scripts/components/auth/ForgotPasswordContainer.tsx | 6 +++++- resources/scripts/components/auth/LoginContainer.tsx | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/scripts/components/auth/ForgotPasswordContainer.tsx b/resources/scripts/components/auth/ForgotPasswordContainer.tsx index 8b75511d0..57f91f4c1 100644 --- a/resources/scripts/components/auth/ForgotPasswordContainer.tsx +++ b/resources/scripts/components/auth/ForgotPasswordContainer.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { useRef, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { Link } from 'react-router-dom'; import requestPasswordResetEmail from '@/api/auth/requestPasswordResetEmail'; import { httpErrorToHuman } from '@/api/http'; @@ -24,6 +24,10 @@ export default () => { const { clearFlashes, addFlash } = useFlash(); const { enabled: recaptchaEnabled, siteKey } = useStoreState(state => state.settings.data!.recaptcha); + useEffect(() => { + clearFlashes(); + }, []); + const handleSubmission = ({ email }: Values, { setSubmitting, resetForm }: FormikHelpers) => { clearFlashes(); diff --git a/resources/scripts/components/auth/LoginContainer.tsx b/resources/scripts/components/auth/LoginContainer.tsx index d74ada61f..8157111ee 100644 --- a/resources/scripts/components/auth/LoginContainer.tsx +++ b/resources/scripts/components/auth/LoginContainer.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { Link, RouteComponentProps } from 'react-router-dom'; import login from '@/api/auth/login'; import LoginFormContainer from '@/components/auth/LoginFormContainer'; @@ -23,6 +23,10 @@ const LoginContainer = ({ history }: RouteComponentProps) => { const { clearFlashes, clearAndAddHttpError } = useFlash(); const { enabled: recaptchaEnabled, siteKey } = useStoreState(state => state.settings.data!.recaptcha); + useEffect(() => { + clearFlashes(); + }, []); + const onSubmit = (values: Values, { setSubmitting }: FormikHelpers) => { clearFlashes();