Skip to content

Commit becd21f

Browse files
committed
Add username to confirmation email and improve message content
1 parent aea1cb0 commit becd21f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

backend/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,12 @@ app.post("/register", async (req, res) => {
170170
if (tokenRows.length > 0) {
171171
const token = tokenRows[0].token;
172172
try {
173-
await sendConfirmationEmail(userEmail, req.headers.host, token);
173+
await sendConfirmationEmail(
174+
userEmail,
175+
username,
176+
req.headers.host,
177+
token
178+
);
174179
res.send(
175180
"Account already exists but is not active. Confirmation email has been resent. Check your inbox and spam folder."
176181
);
@@ -197,7 +202,7 @@ app.post("/register", async (req, res) => {
197202
}
198203

199204
try {
200-
await sendConfirmationEmail(userEmail, req.headers.host, token);
205+
await sendConfirmationEmail(userEmail, username, req.headers.host, token);
201206
} catch (err) {
202207
console.error(err);
203208
res
@@ -225,15 +230,15 @@ app.post("/register", async (req, res) => {
225230
res.send("Check your email for a confirmation link");
226231
});
227232

228-
function sendConfirmationEmail(userEmail, host, token) {
233+
function sendConfirmationEmail(userEmail, username, host, token) {
229234
const mailOptions = {
230235
from: `"${process.env.MAIL_NAME}" <${process.env.MAIL_FROM}>`,
231236
to: userEmail,
232237
subject: "Registration Confirmation for mc.chs.se",
233-
text: `Hello,
238+
text: `Hello ${username},
234239
Please confirm your registration by clicking the following link: http://${host}/confirm/${token}
235240
236-
If you did not request this, please ignore this email.`,
241+
This email was sent from mc.chs.se. If you did not request this, please ignore this email. Contact support@chs.se for assistance.`,
237242
};
238243

239244
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)