Skip to content

[User] Send security email when phone number is cleared#13509

Draft
garyhtou wants to merge 1 commit intogaryhtou/user-phone-number-security-emailfrom
garyhtou/email-on-phone-number-clear
Draft

[User] Send security email when phone number is cleared#13509
garyhtou wants to merge 1 commit intogaryhtou/user-phone-number-security-emailfrom
garyhtou/email-on-phone-number-clear

Conversation

@garyhtou
Copy link
Copy Markdown
Member

Summary

  • Send the "Security settings changed" email when a user's phone number is cleared (value → nil). Clearing the phone number removes SMS 2FA capability, so the account owner should be notified.
  • When the change is made by an admin via impersonation (Current.session&.impersonated?), the email uses alternate copy: "Phone number was removed by HCB support" (vs. "Phone number was removed" for user-initiated clears) so the user isn't confused by a notification for an action they didn't take.

Notes

Test plan

  • New specs in spec/models/user_spec.rb:
    • sends an email when the user clears their own phone_number (with "Phone number was removed")
    • sends an admin-initiated email when an impersonating admin clears the phone_number (with "Phone number was removed by HCB support")
  • Existing security-email specs still pass (11 examples, 0 failures)
  • Manually verify email copy in the mailer preview

🤖 Generated with Claude Code

Previously the security-settings-changed email was suppressed when a
user's phone number went from a value to nil. Clearing a phone number
removes SMS 2FA capability, so the account owner should be notified.

When the change is made by an admin via impersonation, the email uses
alternate copy ("Phone number was removed by HCB support") so the user
isn't confused by a notification for an action they didn't take.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@garyhtou garyhtou marked this pull request as draft April 17, 2026 21:46
Comment thread app/models/user.rb
Comment on lines +255 to +258
"Phone number was removed by HCB support"
else
"Phone number was removed"
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Phone number was removed by HCB support"
else
"Phone number was removed"
end
"Phone number was removed by HCB support"
else
"Phone number was removed"
end

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.

1 participant