Skip to content

Notify old email when email change is requested#1484

Open
maebeale wants to merge 4 commits intomainfrom
maebeale/notify-old-email-change
Open

Notify old email when email change is requested#1484
maebeale wants to merge 4 commits intomainfrom
maebeale/notify-old-email-change

Conversation

@maebeale
Copy link
Copy Markdown
Collaborator

@maebeale maebeale commented Apr 5, 2026

What is the goal of this PR and why is this important?

  • Security measure: alert the user's current (old) email address when an email change is requested
  • Allows account holders to flag unauthorized email changes immediately
  • Follows the same pattern used by other major platforms (GitHub, Google, etc.)

How did you approach the change?

  • Added account_email_change_requested_notification notification kind
  • Created NotificationMailer#account_email_change_requested_notification with a template that warns the old email and links to contact support
  • Wired it up via after_commit :notify_old_email_of_change_request on User, triggered when unconfirmed_email is set
  • Registered the new kind in NotificationMailerJob's mailer map
  • Removed the unused account_email_changed notification kind — it had deliver: false (no email sent), and the same moment is already tracked via Ahoy (auth.email_changed)

UI Testing Checklist

  • Change email on a user account, verify old email receives the alert
  • Verify new email still receives the Devise confirmation email
  • Verify the notification record is created and visible in admin notifications
  • Verify no notification is created for non-email updates

Anything else to add?

  • The email template uses a warm-colored warning box to draw attention
  • account_email_changed was removed because notifications represent emails sent, and this kind never sent one — the Ahoy event auth.email_changed already covers audit needs

🤖 Generated with Claude Code

maebeale and others added 2 commits April 5, 2026 16:07
Security measure: when a user requests an email change, send an alert
to their current (old) email so they can flag unauthorized changes.
Also removes the unused account_email_changed notification kind since
that moment is already tracked via Ahoy (auth.email_changed) and
notifications should represent emails actually sent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verifies the new account_email_change_requested_notification kind
routes correctly through NotificationMailerJob and persists the
delivered email.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@maebeale maebeale marked this pull request as ready for review April 5, 2026 20:23
maebeale and others added 2 commits April 5, 2026 16:24
Update tests to reference account_email_change_requested_notification
instead of the removed account_email_changed kind.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@maebeale maebeale requested a review from jmilljr24 April 5, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants