From 2ebc50a312f06f9f0119773a77889cef287347f0 Mon Sep 17 00:00:00 2001 From: stringsplit <77242831+nbitzz@users.noreply.github.com> Date: Fri, 4 Aug 2023 05:00:48 +0000 Subject: [PATCH] oh im stupid --- src/server/routes/adminRoutes.ts | 9 +++++---- src/server/routes/authRoutes.ts | 16 ++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/server/routes/adminRoutes.ts b/src/server/routes/adminRoutes.ts index 83debcb..7b24baa 100644 --- a/src/server/routes/adminRoutes.ts +++ b/src/server/routes/adminRoutes.ts @@ -49,10 +49,11 @@ adminRoutes.post("/reset", parser, (req,res) => { auth.invalidate(v.token) }) - - sendMail(req.body.email, `Your login details have been updated`, `Hello there! This email is to notify you of a password change that an administrator, ${acc.username}, has initiated. You have been logged out of your devices. Thank you for using monofile.`).then(() => { - res.send("OK") - }).catch((err) => {}) + if (targetAccount.email) { + sendMail(targetAccount.email, `Your login details have been updated`, `Hello there! This email is to notify you of a password change that an administrator, ${acc.username}, has initiated. You have been logged out of your devices. Thank you for using monofile.`).then(() => { + res.send("OK") + }).catch((err) => {}) + } res.send() diff --git a/src/server/routes/authRoutes.ts b/src/server/routes/authRoutes.ts index e27f685..9596eae 100644 --- a/src/server/routes/authRoutes.ts +++ b/src/server/routes/authRoutes.ts @@ -240,9 +240,11 @@ authRoutes.post("/change_username", requiresAccount, parser, (req,res) => { acc.username = req.body.username Accounts.save() - sendMail(req.body.email, `Your login details have been updated`, `Hello there! Your username has been updated to ${req.body.username}. Please update your devices accordingly. Thank you for using monofile.`).then(() => { - res.send("OK") - }).catch((err) => {}) + if (acc.email) { + sendMail(acc.email, `Your login details have been updated`, `Hello there! Your username has been updated to ${req.body.username}. Please update your devices accordingly. Thank you for using monofile.`).then(() => { + res.send("OK") + }).catch((err) => {}) + } res.send("username changed") }) @@ -407,9 +409,11 @@ authRoutes.post("/change_password", requiresAccount, parser, (req,res) => { auth.invalidate(v.token) }) - sendMail(req.body.email, `Your login details have been updated`, `Hello there! This email is to notify you of a password change that you have initiated. You have been logged out of your devices. Thank you for using monofile.`).then(() => { - res.send("OK") - }).catch((err) => {}) + if (acc.email) { + sendMail(acc.email, `Your login details have been updated`, `Hello there! This email is to notify you of a password change that you have initiated. You have been logged out of your devices. Thank you for using monofile.`).then(() => { + res.send("OK") + }).catch((err) => {}) + } res.send("password changed - logged out all sessions") })