feat: distinguish admin-initiated password reset emails
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Admin-sent reset emails now say "Administrator portalu wygenerował link do ustawienia hasła" instead of generic "zażądano resetowania". Validity period shown correctly: 24h for admin, 1h for self-service. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0214cc70f2
commit
8f37ef4ded
@ -580,7 +580,7 @@ def admin_user_reset_password(user_id):
|
||||
if send_email:
|
||||
import email_service
|
||||
if email_service.is_configured():
|
||||
email_sent = email_service.send_password_reset_email(user.email, reset_url)
|
||||
email_sent = email_service.send_password_reset_email(user.email, reset_url, admin_initiated=True)
|
||||
if email_sent:
|
||||
logger.info(f"Password reset email sent to {user.email} by admin {current_user.email}")
|
||||
else:
|
||||
|
||||
@ -416,18 +416,27 @@ def build_message_notification_email(sender_name: str, subject: str, content_pre
|
||||
return html, text
|
||||
|
||||
|
||||
def send_password_reset_email(email: str, reset_url: str) -> bool:
|
||||
def send_password_reset_email(email: str, reset_url: str, admin_initiated: bool = False) -> bool:
|
||||
"""Send password reset email."""
|
||||
subject = "Reset hasła - Norda Biznes Partner"
|
||||
|
||||
body_text = f"""Otrzymałeś ten email, ponieważ zażądano resetowania hasła dla Twojego konta Norda Biznes Partner.
|
||||
if admin_initiated:
|
||||
intro_text = "Administrator portalu Norda Biznes Partner wygenerował dla Ciebie link do ustawienia hasła."
|
||||
intro_html = "Administrator portalu wygenerował dla Ciebie link do ustawienia nowego hasła."
|
||||
validity = "24 godziny"
|
||||
else:
|
||||
intro_text = "Otrzymałeś ten email, ponieważ zażądano resetowania hasła dla Twojego konta Norda Biznes Partner."
|
||||
intro_html = "Otrzymałeś ten email, ponieważ zażądano resetowania hasła dla Twojego konta."
|
||||
validity = "1 godzinę"
|
||||
|
||||
Aby zresetować hasło, kliknij w poniższy link:
|
||||
body_text = f"""{intro_text}
|
||||
|
||||
Aby ustawić hasło, kliknij w poniższy link:
|
||||
{reset_url}
|
||||
|
||||
Link będzie ważny przez 24 godziny.
|
||||
Link będzie ważny przez {validity}.
|
||||
|
||||
Jeśli nie zażądałeś resetowania hasła, zignoruj ten email.
|
||||
Jeśli nie spodziewałeś się tego emaila, skontaktuj się z administratorem.
|
||||
|
||||
---
|
||||
Norda Biznes Partner
|
||||
@ -435,7 +444,7 @@ https://nordabiznes.pl
|
||||
"""
|
||||
|
||||
content = f'''
|
||||
<p style="margin:0 0 20px; color:#1e293b; font-size:16px;">Otrzymałeś ten email, ponieważ zażądano resetowania hasła dla Twojego konta.</p>
|
||||
<p style="margin:0 0 20px; color:#1e293b; font-size:16px;">{intro_html}</p>
|
||||
|
||||
<p style="margin:0 0 24px; color:#475569; font-size:15px;">Kliknij poniższy przycisk, aby ustawić nowe hasło:</p>
|
||||
|
||||
@ -448,7 +457,7 @@ https://nordabiznes.pl
|
||||
<!-- Warning -->
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background:#fef3c7; border-radius:8px; border: 1px solid #fcd34d; margin-bottom:24px;">
|
||||
<tr><td style="padding: 16px;">
|
||||
<p style="margin:0 0 4px; color:#92400e; font-size:14px; font-weight:600;">Ważność linku: 24 godziny</p>
|
||||
<p style="margin:0 0 4px; color:#92400e; font-size:14px; font-weight:600;">Ważność linku: {validity}</p>
|
||||
<p style="margin:0; color:#92400e; font-size:13px;">Po tym czasie konieczne będzie ponowne żądanie resetu hasła.</p>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user