Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def handle_valid_verification_for_authentication_context(auth_method:)
mark_user_session_authenticated(auth_method:, authentication_type: :valid_2fa)
disavowal_event, disavowal_token = create_user_event_with_disavowal(:sign_in_after_2fa)

if IdentityConfig.store.feature_new_device_alert_aggregation_enabled && new_device?
if new_device?
if current_user.sign_in_new_device_at.blank?
if sign_in_notification_timeframe_expired_event.present?
current_user.update(
Expand Down
13 changes: 0 additions & 13 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,6 @@ def personal_key_sign_in(disavowal_token:)
end
end

def new_device_sign_in(date:, location:, device_name:, disavowal_token:)
with_user_locale(user) do
@login_date = date
@login_location = location
@device_name = device_name
@disavowal_token = disavowal_token
mail(
to: email_address.email,
subject: t('user_mailer.new_device_sign_in.subject', app_name: APP_NAME),
)
end
end

# @param [Array<Hash>] events Array of sign-in Event records (event types "sign_in_before_2fa",
# "sign_in_after_2fa", "sign_in_unsuccessful_2fa")
# @param [String] disavowal_token Token to generate URL for disavowing event
Expand Down
26 changes: 3 additions & 23 deletions app/services/user_alerts/alert_user_about_new_device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,8 @@

module UserAlerts
class AlertUserAboutNewDevice
def self.call(event:, device:, disavowal_token:)
return if IdentityConfig.store.feature_new_device_alert_aggregation_enabled
device_decorator = DeviceDecorator.new(device)
login_location = device_decorator.last_sign_in_location_and_ip
device_name = device_decorator.nice_name

event.user.confirmed_email_addresses.each do |email_address|
UserMailer.with(user: event.user, email_address: email_address).new_device_sign_in(
date: device.last_used_at.in_time_zone('Eastern Time (US & Canada)').
strftime('%B %-d, %Y %H:%M Eastern Time'),
location: login_location,
device_name: device_name,
disavowal_token: disavowal_token,
).deliver_now_or_later
end
end

def self.schedule_alert(event:)
return if !IdentityConfig.store.feature_new_device_alert_aggregation_enabled ||
event.user.sign_in_new_device_at.present?
return if event.user.sign_in_new_device_at.present?
event.user.update(sign_in_new_device_at: event.created_at)
end

Expand Down Expand Up @@ -53,10 +35,8 @@ def self.send_alert(user:, disavowal_event:, disavowal_token:)
end

def self.sign_in_events_start_time(user:)
# Avoid scenarios where stale events may be reflected in the time since sign in:
#
# 1. The feature is enabled for a short time in a deployed environment before being disabled
# 2. In local development, the server is not always active and the job may not run until later
# Avoid scenarios where stale events may be reflected in the time since sign in, such as if
# the server is not always active and the job may not run until later.
#
# Typically, it's guaranteed that even in the worst-case of a sign-in occurring immediately
# after a scheduled job run, it should take no longer than twice the scheduled delay. A small
Expand Down
5 changes: 0 additions & 5 deletions app/services/user_event_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def create_event_for_new_device(event_type:, user:, disavowal_token:)
event, disavowal_token = create_user_event_with_disavowal(event_type, user, device)
[device, event, disavowal_token]
end
send_new_device_notification(event:, device:, disavowal_token:)
[event, disavowal_token]
else
Device.transaction do
Expand All @@ -111,10 +110,6 @@ def create_device_for_user(user)
)
end

def send_new_device_notification(event:, device:, disavowal_token:)
UserAlerts::AlertUserAboutNewDevice.call(event:, device:, disavowal_token:)
end

# @return [Array(Event, String)] an (event, disavowal_token) tuple
def create_event_for_device(event_type:, user:, device:, disavowal_token: nil)
disavowal_token_fingerprint = if disavowal_token
Expand Down
41 changes: 0 additions & 41 deletions app/views/user_mailer/new_device_sign_in.html.erb

This file was deleted.

14 changes: 6 additions & 8 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ country_phone_number_overrides: '{}'
database_host: ''
database_name: ''
database_password: ''
database_pool_idp: 5
database_read_replica_host: ''
database_readonly_password: ''
database_readonly_username: ''
database_username: ''
database_worker_jobs_host: ''
database_worker_jobs_name: ''
database_worker_jobs_password: ''
database_worker_jobs_username: ''
database_pool_idp: 5
database_socket: ''
database_sslmode: 'verify-full'
database_statement_timeout: 2_500
database_timeout: 5_000
database_username: ''
database_worker_jobs_host: ''
database_worker_jobs_name: ''
database_worker_jobs_password: ''
database_worker_jobs_sslmode: 'verify-full'
database_worker_jobs_username: ''
deleted_user_accounts_report_configs: '[]'
deliver_mail_async: false
development_mailer_deliver_method: letter_opener
Expand Down Expand Up @@ -115,7 +115,6 @@ enable_usps_verification: true
event_disavowal_expiration_hours: 240
feature_idv_force_gpo_verification_enabled: false
feature_idv_hybrid_flow_enabled: true
feature_new_device_alert_aggregation_enabled: true
geo_data_file_path: 'geo_data/GeoLite2-City.mmdb'
get_usps_proofing_results_job_cron: '0/30 * * * *'
get_usps_proofing_results_job_reprocess_delay_minutes: 5
Expand Down Expand Up @@ -457,7 +456,6 @@ production:
email_registrations_per_ip_track_only_mode: true
enable_test_routes: false
enable_usps_verification: false
feature_new_device_alert_aggregation_enabled: false
hmac_fingerprinter_key:
hmac_fingerprinter_key_queue: '[]'
idv_sp_required: true
Expand Down
14 changes: 5 additions & 9 deletions config/initializers/job_configurations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@
args: -> { [Time.zone.now] },
},
# Send new device alert notifications
create_new_device_alert_send_emails: (
if IdentityConfig.store.feature_new_device_alert_aggregation_enabled
{
class: 'CreateNewDeviceAlert',
cron: cron_5m,
args: -> { [Time.zone.now] },
}
end
),
create_new_device_alert_send_emails: {
class: 'CreateNewDeviceAlert',
cron: cron_5m,
args: -> { [Time.zone.now] },
},
# Send Total Monthly Auths Report to S3
total_monthly_auths: {
class: 'Reports::TotalMonthlyAuthsReport',
Expand Down
4 changes: 0 additions & 4 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1890,10 +1890,6 @@ user_mailer.new_device_sign_in_before_2fa.info_p2: If you recognize this activit
user_mailer.new_device_sign_in_before_2fa.info_p3_html: Two-factor authentication protects your account from unauthorized access. If this wasn’t you, %{reset_password_link_html} immediately.
user_mailer.new_device_sign_in_before_2fa.reset_password: reset your password
user_mailer.new_device_sign_in_before_2fa.subject: New sign-in with your %{app_name} account
user_mailer.new_device_sign_in.disavowal_link: reset your password
user_mailer.new_device_sign_in.help_html: If you did not make this change, %{disavowal_link_html}. For more help, please visit the %{app_name_html} %{help_link_html} or %{contact_link_html}.
user_mailer.new_device_sign_in.info: Your %{app_name} account was just used to sign in on a new device.
user_mailer.new_device_sign_in.subject: New sign-in with your %{app_name} account
user_mailer.password_changed.disavowal_link: reset your password
user_mailer.password_changed.help_html: If you did not make this change, %{disavowal_link_html}. For more help, please visit the %{app_name_html} %{help_link_html} or %{contact_link_html}.
user_mailer.password_changed.intro_html: You have a new password for your %{app_name_html} account.
Expand Down
4 changes: 0 additions & 4 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1902,10 +1902,6 @@ user_mailer.new_device_sign_in_before_2fa.info_p2: Si reconoce esta actividad, n
user_mailer.new_device_sign_in_before_2fa.info_p3_html: La autenticación de dos factores protege su cuenta contra un acceso no autorizado. Si no fue usted, %{reset_password_link_html}.
user_mailer.new_device_sign_in_before_2fa.reset_password: restablezca de inmediato su contraseña.
user_mailer.new_device_sign_in_before_2fa.subject: Nuevo inicio de sesión con su cuenta de %{app_name}
user_mailer.new_device_sign_in.disavowal_link: restablezca su contraseña
user_mailer.new_device_sign_in.help_html: Si usted no hizo este cambio, %{disavowal_link_html}. Para obtener más ayuda, visite %{app_name_html} %{help_link_html} o %{contact_link_html}.
user_mailer.new_device_sign_in.info: Su cuenta de %{app_name} acaba de ser usada para iniciar sesión en un nuevo dispositivo.
user_mailer.new_device_sign_in.subject: Nuevo inicio de sesión con su cuenta de %{app_name}
user_mailer.password_changed.disavowal_link: restablezca su contraseña
user_mailer.password_changed.help_html: Si usted no hizo este cambio, %{disavowal_link_html}. Para obtener más ayuda, visite %{app_name_html} %{help_link_html} o %{contact_link_html}.
user_mailer.password_changed.intro_html: Tiene una contraseña nueva para su cuenta de %{app_name_html}.
Expand Down
4 changes: 0 additions & 4 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1890,10 +1890,6 @@ user_mailer.new_device_sign_in_before_2fa.info_p2: Si vous reconnaissez cette ac
user_mailer.new_device_sign_in_before_2fa.info_p3_html: L’authentification à deux facteurs protège votre compte des accès non autorisés. Si vous n’êtes pas à l’origine de cette action, %{reset_password_link_html}.
user_mailer.new_device_sign_in_before_2fa.reset_password: veuillez réinitialiser immédiatement votre mot de passe.
user_mailer.new_device_sign_in_before_2fa.subject: Nouvelle connexion avec votre compte %{app_name}
user_mailer.new_device_sign_in.disavowal_link: réinitialisez votre mot de passe
user_mailer.new_device_sign_in.help_html: Si vous n’avez pas effectué ce changement, %{disavowal_link_html}. Pour plus d’aide, veuillez visiter le %{help_link_html} de %{app_name_html} ou %{contact_link_html}.
user_mailer.new_device_sign_in.info: Votre compte %{app_name} vient d’être utilisé pour une connexion sur un nouvel appareil.
user_mailer.new_device_sign_in.subject: Nouvelle connexion avec votre compte %{app_name}
user_mailer.password_changed.disavowal_link: réinitialisez votre mot de passe
user_mailer.password_changed.help_html: Si vous n’avez pas effectué ce changement, %{disavowal_link_html}. Pour plus d’aide, veuillez visiter le %{help_link_html} de %{app_name_html} ou %{contact_link_html}.
user_mailer.password_changed.intro_html: Vous avez un nouveau mot de passe pour votre compte %{app_name_html}.
Expand Down
4 changes: 0 additions & 4 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1903,10 +1903,6 @@ user_mailer.new_device_sign_in_before_2fa.info_p2: 如果你知道该活动,
user_mailer.new_device_sign_in_before_2fa.info_p3_html: 双重身份验证保护你账户不受未经授权的访问。如果不是你,请马上 %{reset_password_link_html}.
user_mailer.new_device_sign_in_before_2fa.reset_password: 重设密码
user_mailer.new_device_sign_in_before_2fa.subject: 你 %{app_name} 账户有新的登录
user_mailer.new_device_sign_in.disavowal_link: 重设你的密码
user_mailer.new_device_sign_in.help_html: 如果你没做此更改, %{disavowal_link_html}。要得到更多帮助,请访问 %{app_name_html} %{help_link_html} 或者 %{contact_link_html}。
user_mailer.new_device_sign_in.info: 你的 %{app_name} 帐号刚刚在一个新设备上用于登录。
user_mailer.new_device_sign_in.subject: 用你 %{app_name} 账户进行的新登录
user_mailer.password_changed.disavowal_link: 重设你的密码
user_mailer.password_changed.help_html: 如果你没做此更改, %{disavowal_link_html}。要得到更多帮助,请访问 %{app_name_html} %{help_link_html} 或者 %{contact_link_html}。
user_mailer.password_changed.intro_html: 你的 %{app_name_html} 账户有了新密码。
Expand Down
1 change: 0 additions & 1 deletion lib/identity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def self.store
config.add(:event_disavowal_expiration_hours, type: :integer)
config.add(:feature_idv_force_gpo_verification_enabled, type: :boolean)
config.add(:feature_idv_hybrid_flow_enabled, type: :boolean)
config.add(:feature_new_device_alert_aggregation_enabled, type: :boolean)
config.add(:geo_data_file_path, type: :string)
config.add(:get_usps_proofing_results_job_cron, type: :string)
config.add(:get_usps_proofing_results_job_reprocess_delay_minutes, type: :integer)
Expand Down
Loading