Skip to content

Commit

Permalink
fix issue 1770:changed error handling of attempting to send passwork …
Browse files Browse the repository at this point in the history
…reset on nonexistent user: view issue 1770
  • Loading branch information
zg009 committed Mar 15, 2024
1 parent d8290cb commit 00629ef
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 213 deletions.
11 changes: 10 additions & 1 deletion lib/requests/password-reset-email-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ class PasswordResetEmailRequest extends AuthRequest {
return Promise.resolve()
.then(() => request.validate())
.then(() => request.loadUser())
.catch((err) => {
if (err.code === "ACCOUNT_MISSING") {
this.response.render('auth/reset-link-sent')
} else {
return err;
}
})
.then(userAccount => request.sendResetLink(userAccount))
.then(() => request.renderSuccess())
.catch(error => request.error(error))
Expand Down Expand Up @@ -123,7 +130,9 @@ class PasswordResetEmailRequest extends AuthRequest {
return this.accountManager.accountExists(username)
.then(exists => {
if (!exists) {
throw new Error('Account not found for that username')
const error = new Error("Account not found for that username")
error.code = "ACCOUNT_MISSING"
throw error
}

const userData = { username }
Expand Down
Loading

0 comments on commit 00629ef

Please sign in to comment.