aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/users/index.ts2
-rw-r--r--server/lib/emailer.ts6
-rw-r--r--server/lib/emails/password-reset/html.pug6
-rw-r--r--server/lib/user.ts3
4 files changed, 10 insertions, 7 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index fcd828ae3..5939f6125 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -340,7 +340,7 @@ async function askResetUserPassword (req: express.Request, res: express.Response
340 340
341 const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id) 341 const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id)
342 const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString 342 const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString
343 await Emailer.Instance.addPasswordResetEmailJob(user.email, url) 343 await Emailer.Instance.addPasswordResetEmailJob(user.username, user.email, url)
344 344
345 return res.status(204).end() 345 return res.status(204).end()
346} 346}
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index d54eab966..48ba7421e 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -427,12 +427,13 @@ class Emailer {
427 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 427 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
428 } 428 }
429 429
430 addPasswordResetEmailJob (to: string, resetPasswordUrl: string) { 430 addPasswordResetEmailJob (username: string, to: string, resetPasswordUrl: string) {
431 const emailPayload: EmailPayload = { 431 const emailPayload: EmailPayload = {
432 template: 'password-reset', 432 template: 'password-reset',
433 to: [ to ], 433 to: [ to ],
434 subject: 'Reset your account password', 434 subject: 'Reset your account password',
435 locals: { 435 locals: {
436 username,
436 resetPasswordUrl 437 resetPasswordUrl
437 } 438 }
438 } 439 }
@@ -454,12 +455,13 @@ class Emailer {
454 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 455 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
455 } 456 }
456 457
457 addVerifyEmailJob (to: string, verifyEmailUrl: string) { 458 addVerifyEmailJob (username: string, to: string, verifyEmailUrl: string) {
458 const emailPayload: EmailPayload = { 459 const emailPayload: EmailPayload = {
459 template: 'verify-email', 460 template: 'verify-email',
460 to: [ to ], 461 to: [ to ],
461 subject: `Verify your email on ${WEBSERVER.HOST}`, 462 subject: `Verify your email on ${WEBSERVER.HOST}`,
462 locals: { 463 locals: {
464 username,
463 verifyEmailUrl 465 verifyEmailUrl
464 } 466 }
465 } 467 }
diff --git a/server/lib/emails/password-reset/html.pug b/server/lib/emails/password-reset/html.pug
index bb6a9d16b..ac33db5d7 100644
--- a/server/lib/emails/password-reset/html.pug
+++ b/server/lib/emails/password-reset/html.pug
@@ -5,8 +5,8 @@ block title
5 5
6block content 6block content
7 p. 7 p.
8 A reset password procedure for your account ${to} has been requested on #[a(href=WEBSERVER.URL) #{WEBSERVER.HOST}]. 8 A reset password procedure for your account #{username} has been requested on #[a(href=WEBSERVER.URL) #{WEBSERVER.HOST}].
9 Please follow #[a(href=resetPasswordUrl) this link] to reset it: #[a(href=resetPasswordUrl) #{resetPasswordUrl}] 9 Please follow #[a(href=resetPasswordUrl) this link] to reset it: #[a(href=resetPasswordUrl) #{resetPasswordUrl}]
10 (the link will expire within 1 hour) 10 (the link will expire within 1 hour)
11 p. 11 p.
12 If you are not the person who initiated this request, please ignore this email. \ No newline at end of file 12 If you are not the person who initiated this request, please ignore this email.
diff --git a/server/lib/user.ts b/server/lib/user.ts
index 642549879..6e7a738ee 100644
--- a/server/lib/user.ts
+++ b/server/lib/user.ts
@@ -111,8 +111,9 @@ async function sendVerifyUserEmail (user: MUser, isPendingEmail = false) {
111 if (isPendingEmail) url += '&isPendingEmail=true' 111 if (isPendingEmail) url += '&isPendingEmail=true'
112 112
113 const email = isPendingEmail ? user.pendingEmail : user.email 113 const email = isPendingEmail ? user.pendingEmail : user.email
114 const username = user.username
114 115
115 await Emailer.Instance.addVerifyEmailJob(email, url) 116 await Emailer.Instance.addVerifyEmailJob(username, email, url)
116} 117}
117 118
118// --------------------------------------------------------------------------- 119// ---------------------------------------------------------------------------