Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions task-api/src/utils/mailer.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,29 @@ export class MailerUtil {

private static buildBodies(resetUrl: string): { text: string; html: string } {
const text = [
'Reset your Task Management password',
'Reset your password',
'',
'We received a request to reset your password. Open this link (expires in 1 hour):',
'Someone requested a password reset for your Task Management account.',
'Use this link within the next hour to choose a new password:',
resetUrl,
'',
'If you did not request this, you can ignore this email.',
'If you did not make this request, you can safely ignore this email. Your password will stay the same.',
].join('\n');

const html = `
<!DOCTYPE html>
<html>
<body style="font-family: system-ui, sans-serif; line-height: 1.5; color: #111; max-width: 480px; margin: 0 auto; padding: 24px;">
<h1 style="font-size: 20px; margin: 0 0 16px;">Reset your password</h1>
<p style="margin: 0 0 16px;">We received a request to reset your Task Management password. This link expires in <strong>1 hour</strong>.</p>
<p style="margin: 0 0 16px;">Someone requested a password reset for your Task Management account. Click the button below to choose a new password. This link expires in <strong>1 hour</strong>.</p>
<p style="margin: 0 0 24px;">
<a href="${resetUrl}" style="display: inline-block; background: #111; color: #fff; text-decoration: none; padding: 12px 18px; border-radius: 6px; font-weight: 600;">
Reset password
Choose a new password
</a>
</p>
<p style="margin: 0 0 8px; font-size: 13px; color: #555;">Or copy this link:</p>
<p style="margin: 0 0 8px; font-size: 13px; color: #555;">Or paste this link into your browser:</p>
<p style="margin: 0 0 24px; font-size: 12px; word-break: break-all; color: #333;">${resetUrl}</p>
<p style="margin: 0; font-size: 13px; color: #777;">If you did not request this, you can ignore this email.</p>
<p style="margin: 0; font-size: 13px; color: #777;">If you did not make this request, you can safely ignore this email. Your password will stay the same.</p>
</body>
</html>`.trim();

Expand Down Expand Up @@ -103,7 +104,7 @@ export class MailerUtil {
.sendMail({
from,
to,
subject: 'Reset your Task Management password',
subject: 'Reset your password — Task Management',
text,
html,
})
Expand Down Expand Up @@ -145,7 +146,7 @@ export class MailerUtil {
body: JSON.stringify({
from,
to: [to],
subject: 'Reset your Task Management password',
subject: 'Reset your password — Task Management',
text,
html,
}),
Expand Down
3 changes: 2 additions & 1 deletion task-api/tests/auth-tasks.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ describe('API + DB integration', () => {
const body = JSON.parse(String(init.body));
expect(body.to).toEqual([email]);
expect(body.subject).toMatch(/reset/i);
expect(body.html).toMatch(/Reset password/);
expect(body.html).toMatch(/Choose a new password/);
expect(body.text).toMatch(/reset-password\?token=/);
expect(body.html).toMatch(/http:\/\/localhost:3000\/reset-password\?token=/);
expect(body.html).toMatch(/safely ignore/i);
} finally {
global.fetch = originalFetch;
clearMailerEnv();
Expand Down
Loading