Skip to content

Commit

Permalink
Include the user's handle in the reset password email (bluesky-social…
Browse files Browse the repository at this point in the history
…#489)

* Include the user's handle in the reset password email (close bluesky-social#486)

* Add test for handle in reset-code email

* Linter fix
  • Loading branch information
pfrazee authored Jan 26, 2023
1 parent 49d31f0 commit ff94297
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/pds/src/api/com/atproto/password-reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export default function (server: Server, ctx: AppContext) {
passwordResetGrantedAt: grantedAt,
})
.execute()
await ctx.mailer.sendResetPassword({ token }, { to: user.email })
await ctx.mailer.sendResetPassword(
{ handle: user.handle, token },
{ to: user.email },
)
}
})

Expand Down
5 changes: 4 additions & 1 deletion packages/pds/src/mailer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export class ServerMailer {
}
}

async sendResetPassword(params: { token: string }, mailOpts: Mail.Options) {
async sendResetPassword(
params: { handle: string; token: string },
mailOpts: Mail.Options,
) {
return this.sendTemplate('resetPassword', params, {
subject: 'Password Reset Requested',
...mailOpts,
Expand Down
5 changes: 3 additions & 2 deletions packages/pds/src/mailer/templates/reset-password.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@
class="text-teal-700"
style="color: #13795b; padding-top: 0; padding-bottom: 0; font-weight: 500; vertical-align: baseline; font-size: 20px; line-height: 24px; margin: 0;"
align="left"
>We received a request to reset your
account password.</h5>
>We received a request to reset the
password for the account:
{{handle}}</h5>
<table
class="s-5 w-full"
role="presentation"
Expand Down
1 change: 1 addition & 0 deletions packages/pds/tests/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ describe('account', () => {

expect(mail.to).toEqual(email)
expect(mail.html).toContain('Reset your password')
expect(mail.html).toContain('alice.test')

const token = getTokenFromMail(mail)

Expand Down

0 comments on commit ff94297

Please sign in to comment.