From 45e7f162a24fe1d3b10c0b84aed209d0a3fcec3b Mon Sep 17 00:00:00 2001
From: KernelDeimos
Date: Wed, 8 May 2024 16:01:20 -0400
Subject: [PATCH] Add password change notification
---
packages/backend/src/routers/passwd.js | 4 ++++
packages/backend/src/services/EmailService.js | 11 +++++++++++
2 files changed, 15 insertions(+)
diff --git a/packages/backend/src/routers/passwd.js b/packages/backend/src/routers/passwd.js
index 7d8beb77d..6fada5ed3 100644
--- a/packages/backend/src/routers/passwd.js
+++ b/packages/backend/src/routers/passwd.js
@@ -66,6 +66,10 @@ router.post('/passwd', auth, express.json(), async (req, res, next)=>{
[await bcrypt.hash(req.body.new_pass, 8), req.user.id]
);
invalidate_cached_user(req.user);
+
+ const svc_email = req.services.get('email');
+ svc_email.send_email({ email: user.email }, 'password_change_notification');
+
return res.send('Password successfully updated.')
}
}catch(e){
diff --git a/packages/backend/src/services/EmailService.js b/packages/backend/src/services/EmailService.js
index ed140aeec..c328df5d3 100644
--- a/packages/backend/src/services/EmailService.js
+++ b/packages/backend/src/services/EmailService.js
@@ -69,6 +69,17 @@ If this was not you, please contact support@puter.com immediately.
`,
},
+ 'password_change_notification': {
+ subject: '\u{1f511} Password change notification',
+ html: /*html*/`
+ Hi there,
+
+ We're sending an email to let you know about a change to your account.
+ Your password was recently changed. If this was not you, please contact
+ support@puter.com immediately.
+
+ `,
+ },
'email_verification_code': {
subject: `{{code}} is your confirmation code`,
html: /*html*/`