Skip to content

Success for sending password email is reported to user even when it actually failed due to server misconfiguration #13885

@CherryDT

Description

@CherryDT

Describe the Bug

When sending email fails, for example due to bad credentials, POST /api/admins/forgot-password does correctly return a 500 error, but the built-in UI still shows a success in that case, it claims the email was sent when it actually wasn't, and the user is none the wiser.

Note that I do not mean the case where the email does not exist in the database, I'm talking about a server misconfiguration, problem with the email server, etc.

Image

Root Cause

The issue is here (no check for response.ok):

const handleResponse: FormProps['handleResponse'] = (res, successToast, errorToast) => {
res
.json()
.then(() => {
setHasSubmitted(true)
successToast(t('general:submissionSuccessful'))
})
.catch(() => {
errorToast(
loginWithUsername
? t('authentication:usernameNotValid')
: t('authentication:emailNotValid'),
)
})
}

Link to the code that reproduces this issue

unnecessary, any app will do once you change the email config to a bad one

Reproduction Steps

Create a blank project, set some bad email configuration in it that isn't blank, for example some SMTP configuration with bad credentials. Then try to use the forgot password form.

Which area(s) are affected? (Select all that apply)

area: ui

Environment Info

Irrelevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-triagePossible bug which hasn't been reproduced yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions