Only send notification emails to verified users

Adds verified? check to bundling_emails? to prevent notification emails
from being sent to users who have never authenticated. This closes the
spam vector where bad actors could create users for known email
addresses and trigger unwanted notifications by mentioning them.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Mike Dalessio
2025-12-05 08:45:42 -05:00
parent e174206233
commit 1ad52d2590
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ class User::Settings < ApplicationRecord
end
def bundling_emails?
!bundle_email_never? && !user.system? && user.active?
!bundle_email_never? && !user.system? && user.active? && user.verified?
end
def timezone
+4
View File
@@ -49,5 +49,9 @@ class User::SettingsTest < ActiveSupport::TestCase
@user.update!(role: :member, active: false)
assert_not @user.settings.bundling_emails?, "Inactive users should not receive bundled emails"
@user.update!(active: true)
@user.update_column(:verified_at, nil)
assert_not @user.settings.bundling_emails?, "Unverified users should not receive bundled emails"
end
end