Skip to content

Commit bf4fd10

Browse files
authored
improve password reset email (#183)
* add fancier password reset email template * use new email template, set token expiry * use a body tag, i guess
1 parent 0907644 commit bf4fd10

File tree

2 files changed

+94
-2
lines changed

2 files changed

+94
-2
lines changed

colandr/api/v1/routes/auth.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
import urllib.parse
23

34
import apiflask as af
@@ -215,13 +216,21 @@ def post(self, query_data):
215216
)
216217
return
217218

218-
access_token = jwtext.create_access_token(identity=user, fresh=False)
219+
token_expiration_minutes = 15
220+
access_token = jwtext.create_access_token(
221+
identity=user,
222+
fresh=False,
223+
expires_delta=datetime.timedelta(minutes=token_expiration_minutes),
224+
)
219225
confirm_url = url_for("auth.reset_confirm", token=access_token, _external=True)
220226
if fe_app_site := current_app.config["FE_APP_SITE"]:
221227
confirm_url = _replace_url_site(confirm_url, fe_app_site)
222228

223229
html = render_template(
224-
"emails/password_reset.html", url=confirm_url, name=user.name
230+
"emails/password_reset_v2.html",
231+
url=confirm_url,
232+
name=user.name,
233+
expiration_minutes=token_expiration_minutes,
225234
)
226235
if current_app.config["MAIL_SERVER"]:
227236
tasks.send_email.apply_async(
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Colandr - reset your password</title>
8+
</head>
9+
10+
<body
11+
style="margin: 0; padding: 0; background-color: #f5f7fa; font-family: Arial, Helvetica, sans-serif; line-height: 1.6;">
12+
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"
13+
style="border-collapse: collapse;">
14+
<tr>
15+
<td align="center" style="padding: 40px 0;">
16+
<table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0"
17+
style="max-width: 600px; background-color: #ffffff; border: 1px solid #e5e7eb; border-collapse: collapse;">
18+
<!-- Header -->
19+
<tr>
20+
<td style="background-color: #4353b3; padding: 32px 40px; text-align: center;">
21+
<h1 style="font-size: 24px; font-weight: 700; color: #ffffff; margin: 0;">colandr</h1>
22+
</td>
23+
</tr>
24+
25+
<!-- Content -->
26+
<tr>
27+
<td style="padding: 40px 40px 32px;">
28+
<h3 style="font-size: 18px; font-weight: 600; color: #1f2937; margin: 0 0 24px 0;">Hi,
29+
{{ name }}!</h3>
30+
<p style="font-size: 15px; color: #4b5563; margin: 0 0 0 0; line-height: 1.7;">
31+
A password reset request has recently been made for this email address. Please click
32+
the link below to reset it. This link will expire in {{ expiration_minutes }}
33+
minutes.
34+
</p>
35+
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"
36+
style="border-collapse: collapse;">
37+
<tr>
38+
<td align="center" style="padding: 24px 0;">
39+
<a href="{{ url }}" target="_blank"
40+
style="display: inline-block; padding: 14px 36px; background-color: #4353b3; color: #ffffff; text-decoration: none; font-weight: 600; font-size: 15px;">reset
41+
my password</a>
42+
</td>
43+
</tr>
44+
</table>
45+
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"
46+
style="border-collapse: collapse;">
47+
<tr>
48+
<td
49+
style="padding: 14px 16px; background-color: #fef3c7; border-left: 3px solid #f59e0b; font-size: 13px; color: #92400e;">
50+
<strong>Note:</strong> If you didn't request this password reset, you can
51+
safely ignore this email.
52+
</td>
53+
</tr>
54+
</table>
55+
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"
56+
style="border-collapse: collapse;">
57+
<tr>
58+
<td
59+
style="padding-top: 32px; border-top: 1px solid #e5e7eb; font-size: 15px; color: #1f2937;">
60+
<p style="font-weight: 600; margin: 0;">Cheers,</p>
61+
<p style="margin: 4px 0 0 0; color: #6b7280;">The Colandr Team</p>
62+
</td>
63+
</tr>
64+
</table>
65+
</td>
66+
</tr>
67+
68+
<!-- Footer -->
69+
<tr>
70+
<td
71+
style="padding: 24px 40px; text-align: center; font-size: 12px; color: #9ca3af; background-color: #f9fafb; border-top: 1px solid #e5e7eb;">
72+
<p style="margin: 4px 0;">This is an automated message. Please do not reply to this
73+
email.</p>
74+
<p style="margin: 4px 0;">&copy; 2026 colandr. All rights reserved.</p>
75+
</td>
76+
</tr>
77+
</table>
78+
</td>
79+
</tr>
80+
</table>
81+
</body>
82+
83+
</html>

0 commit comments

Comments
 (0)