Skip to content

Commit 1d8cf21

Browse files
committed
Send email when a password is changed
1 parent c19011a commit 1d8cf21

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

change_password_notification.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Forum Password Change Notification</title>
6+
</head>
7+
<body>
8+
<p>The password for your forum account has just been changed.</p>
9+
</body>
10+
</html>

routes/custom_account.js

+9
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function randomPassword() {
6666

6767
const emailRegisterTemplate = fs.readFileSync(__dirname + '/../register_confirmation_template.html', 'utf8');
6868
const emailForgotPasswordTemplate = fs.readFileSync(__dirname + '/../reset_password_confirmation_template.html', 'utf8');
69+
const emailPasswordChangeTemplate = fs.readFileSync(__dirname + '/../change_password_notification.html', 'utf8');
6970

7071
function emailRegistrationConfirmation(email, confirmationId) {
7172

@@ -81,6 +82,12 @@ function emailResetPasswordLink(email, resetId) {
8182
emailService.sendEmail(email, constants.resetPasswordConfirmationTitle, messageBody, messageBody);
8283
}
8384

85+
function emailPasswordChangeNotificationLink(email) {
86+
87+
const messageBody = emailPasswordChangeTemplate;
88+
emailService.sendEmail(email, constants.passwordChangeNotificationTitle, messageBody, messageBody);
89+
}
90+
8491
async function registerUserAndGetConfirmationId(email, password, minAge) {
8592

8693
const transformedPassword = await passwordService.transformPasswordInitial(password);
@@ -352,6 +359,8 @@ if (constants.enableCustomAuth) {
352359

353360
if (await changePassword(input.email, input.oldPassword, input.newPassword)) {
354361

362+
emailPasswordChangeNotificationLink(input.email);
363+
355364
res.sendJson({
356365
status: constants.statusCodes.ok
357366
});

services/constants.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = {
2626
registrationConfirmationUrl: process.env.REGISTER_CONFIRMATION_URL,
2727
registrationConfirmationRedirectUrl: process.env.REGISTER_CONFIRMATION_REDIRECT_URL,
2828
registrationConfirmationTitle: process.env.REGISTER_CONFIRMATION_TITLE,
29+
passwordChangeNotificationTitle: process.env.PASSWORD_CHANGE_NOTIFICATION_TITLE,
2930
resetPasswordConfirmationTitle: process.env.RESET_PASSWORD_CONFIRMATION_TITLE,
3031
resetPasswordConfirmationUrl: process.env.RESET_PASSWORD_CONFIRMATION_URL,
3132
resetPasswordConfirmationTimeoutSeconds: parseInt(process.env.RESET_PASSWORD_TIMEOUT_SECONDS),

0 commit comments

Comments
 (0)