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 c08732b48..ee8498c41 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -387,12 +387,13 @@ class Emailer {
387 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 387 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
388 } 388 }
389 389
390 addPasswordResetEmailJob (to: string, resetPasswordUrl: string) { 390 addPasswordResetEmailJob (username: string, to: string, resetPasswordUrl: string) {
391 const emailPayload: EmailPayload = { 391 const emailPayload: EmailPayload = {
392 template: 'password-reset', 392 template: 'password-reset',
393 to: [ to ], 393 to: [ to ],
394 subject: 'Reset your account password', 394 subject: 'Reset your account password',
395 locals: { 395 locals: {
396 username,
396 resetPasswordUrl 397 resetPasswordUrl
397 } 398 }
398 } 399 }
@@ -414,12 +415,13 @@ class Emailer {
414 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 415 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
415 } 416 }
416 417
417 addVerifyEmailJob (to: string, verifyEmailUrl: string) { 418 addVerifyEmailJob (username: string, to: string, verifyEmailUrl: string) {
418 const emailPayload: EmailPayload = { 419 const emailPayload: EmailPayload = {
419 template: 'verify-email', 420 template: 'verify-email',
420 to: [ to ], 421 to: [ to ],
421 subject: `Verify your email on ${WEBSERVER.HOST}`, 422 subject: `Verify your email on ${WEBSERVER.HOST}`,
422 locals: { 423 locals: {
424 username,
423 verifyEmailUrl 425 verifyEmailUrl
424 } 426 }
425 } 427 }
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 43eef8ab1..dabb35061 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// ---------------------------------------------------------------------------