Skip to content

Commit

Permalink
Display error for password reset with no user found (#12417)
Browse files Browse the repository at this point in the history
* display error message if firebase can't retrieve user/other server error

* fix react intl error
  • Loading branch information
teallarson authored Apr 29, 2022
1 parent 6897a60 commit e08f47b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions airbyte-webapp/src/packages/cloud/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"login.resendEmail": "Didn’t receive the email? Send it again",
"login.yourEmail": "Your work email*",
"login.yourEmail.placeholder": "[email protected]",
"login.yourEmail.notFound": "User not found",
"login.unknownError": "An unknown error has occurred",
"login.password": "Enter your password*",
"login.password.placeholder": "Enter a strong password",
"login.yourPassword": "Enter your password*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ResetPasswordPageValidationSchema = yup.object().shape({
const ResetPasswordPage: React.FC = () => {
const { requirePasswordReset } = useAuthService();
const { registerNotification } = useNotificationService();
const formatMessage = useIntl().formatMessage;
const { formatMessage } = useIntl();

return (
<div>
Expand All @@ -32,13 +32,19 @@ const ResetPasswordPage: React.FC = () => {
email: "",
}}
validationSchema={ResetPasswordPageValidationSchema}
onSubmit={async ({ email }) => {
await requirePasswordReset(email);
registerNotification({
id: "resetPassword.emailSent",
title: formatMessage({ id: "login.resetPassword.emailSent" }),
isError: false,
});
onSubmit={async ({ email }, FormikBag) => {
try {
await requirePasswordReset(email);
registerNotification({
id: "resetPassword.emailSent",
title: formatMessage({ id: "login.resetPassword.emailSent" }),
isError: false,
});
} catch (err) {
err.message.includes("user-not-found")
? FormikBag.setFieldError("email", "login.yourEmail.notFound")
: FormikBag.setFieldError("email", "login.unknownError");
}
}}
validateOnBlur={true}
validateOnChange={false}
Expand Down

0 comments on commit e08f47b

Please sign in to comment.