Fix: display username in password-reset and verify-email notifs
This commit is contained in:
parent
0bdad52fbb
commit
963023abe6
4 changed files with 10 additions and 7 deletions
|
@ -340,7 +340,7 @@ async function askResetUserPassword (req: express.Request, res: express.Response
|
||||||
|
|
||||||
const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id)
|
const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id)
|
||||||
const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString
|
const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString
|
||||||
await Emailer.Instance.addPasswordResetEmailJob(user.email, url)
|
await Emailer.Instance.addPasswordResetEmailJob(user.username, user.email, url)
|
||||||
|
|
||||||
return res.status(204).end()
|
return res.status(204).end()
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,12 +387,13 @@ class Emailer {
|
||||||
return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
|
return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
|
||||||
}
|
}
|
||||||
|
|
||||||
addPasswordResetEmailJob (to: string, resetPasswordUrl: string) {
|
addPasswordResetEmailJob (username: string, to: string, resetPasswordUrl: string) {
|
||||||
const emailPayload: EmailPayload = {
|
const emailPayload: EmailPayload = {
|
||||||
template: 'password-reset',
|
template: 'password-reset',
|
||||||
to: [ to ],
|
to: [ to ],
|
||||||
subject: 'Reset your account password',
|
subject: 'Reset your account password',
|
||||||
locals: {
|
locals: {
|
||||||
|
username,
|
||||||
resetPasswordUrl
|
resetPasswordUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,12 +415,13 @@ class Emailer {
|
||||||
return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
|
return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
|
||||||
}
|
}
|
||||||
|
|
||||||
addVerifyEmailJob (to: string, verifyEmailUrl: string) {
|
addVerifyEmailJob (username: string, to: string, verifyEmailUrl: string) {
|
||||||
const emailPayload: EmailPayload = {
|
const emailPayload: EmailPayload = {
|
||||||
template: 'verify-email',
|
template: 'verify-email',
|
||||||
to: [ to ],
|
to: [ to ],
|
||||||
subject: `Verify your email on ${WEBSERVER.HOST}`,
|
subject: `Verify your email on ${WEBSERVER.HOST}`,
|
||||||
locals: {
|
locals: {
|
||||||
|
username,
|
||||||
verifyEmailUrl
|
verifyEmailUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ block title
|
||||||
|
|
||||||
block content
|
block content
|
||||||
p.
|
p.
|
||||||
A reset password procedure for your account ${to} has been requested on #[a(href=WEBSERVER.URL) #{WEBSERVER.HOST}].
|
A reset password procedure for your account #{username} has been requested on #[a(href=WEBSERVER.URL) #{WEBSERVER.HOST}].
|
||||||
Please follow #[a(href=resetPasswordUrl) this link] to reset it: #[a(href=resetPasswordUrl) #{resetPasswordUrl}]
|
Please follow #[a(href=resetPasswordUrl) this link] to reset it: #[a(href=resetPasswordUrl) #{resetPasswordUrl}]
|
||||||
(the link will expire within 1 hour)
|
(the link will expire within 1 hour)
|
||||||
p.
|
p.
|
||||||
|
|
|
@ -111,8 +111,9 @@ async function sendVerifyUserEmail (user: MUser, isPendingEmail = false) {
|
||||||
if (isPendingEmail) url += '&isPendingEmail=true'
|
if (isPendingEmail) url += '&isPendingEmail=true'
|
||||||
|
|
||||||
const email = isPendingEmail ? user.pendingEmail : user.email
|
const email = isPendingEmail ? user.pendingEmail : user.email
|
||||||
|
const username = user.username
|
||||||
|
|
||||||
await Emailer.Instance.addVerifyEmailJob(email, url)
|
await Emailer.Instance.addVerifyEmailJob(username, email, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue