From 14cd1744ff0f717f8235c004836f778446cef433 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 18 May 2021 15:48:28 +0100 Subject: [PATCH] Updating reset link to match that of the builder. --- packages/worker/src/api/controllers/admin/auth.js | 11 +++++++---- packages/worker/src/utilities/email.js | 4 ++++ packages/worker/src/utilities/templates.js | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/worker/src/api/controllers/admin/auth.js b/packages/worker/src/api/controllers/admin/auth.js index 7298d726b3..5304ac85d1 100644 --- a/packages/worker/src/api/controllers/admin/auth.js +++ b/packages/worker/src/api/controllers/admin/auth.js @@ -54,10 +54,13 @@ exports.reset = async ctx => { } try { const user = await getGlobalUserByEmail(email) - await sendEmail(email, EmailTemplatePurpose.PASSWORD_RECOVERY, { - user, - subject: "{{ company }} platform password reset", - }) + // only if user exists, don't error though if they don't + if (user) { + await sendEmail(email, EmailTemplatePurpose.PASSWORD_RECOVERY, { + user, + subject: "{{ company }} platform password reset", + }) + } } catch (err) { // don't throw any kind of error to the user, this might give away something } diff --git a/packages/worker/src/utilities/email.js b/packages/worker/src/utilities/email.js index 8d383b385c..179f662a96 100644 --- a/packages/worker/src/utilities/email.js +++ b/packages/worker/src/utilities/email.js @@ -117,6 +117,10 @@ async function getSmtpConfiguration(db, groupId = null) { * @return {Promise} returns true if there is a configuration that can be used. */ exports.isEmailConfigured = async (groupId = null) => { + // when "testing" simply return true + if (TEST_MODE) { + return true + } const db = new CouchDB(GLOBAL_DB) const config = await getSmtpConfiguration(db, groupId) return config != null diff --git a/packages/worker/src/utilities/templates.js b/packages/worker/src/utilities/templates.js index 5e712eea1c..86436a2f29 100644 --- a/packages/worker/src/utilities/templates.js +++ b/packages/worker/src/utilities/templates.js @@ -35,7 +35,7 @@ exports.getSettingsTemplateContext = async (purpose, code = null) => { case EmailTemplatePurpose.PASSWORD_RECOVERY: context[InternalTemplateBindings.RESET_CODE] = code context[InternalTemplateBindings.RESET_URL] = checkSlashesInUrl( - `${URL}/reset?code=${code}` + `${URL}/builder/auth/reset?code=${code}` ) break case EmailTemplatePurpose.INVITATION: