diff --git a/app/controllers/sign_up/email_confirmations_controller.rb b/app/controllers/sign_up/email_confirmations_controller.rb index 86a31240db4..21e66b4399e 100644 --- a/app/controllers/sign_up/email_confirmations_controller.rb +++ b/app/controllers/sign_up/email_confirmations_controller.rb @@ -22,7 +22,6 @@ def clear_setup_piv_cac_from_sign_in def process_successful_confirmation process_valid_confirmation_token request_id = params.fetch(:_request_id, '') - Funnel::Registration::ConfirmEmail.call(@user.id) redirect_to sign_up_enter_password_url( request_id: request_id, confirmation_token: @confirmation_token, ) diff --git a/app/controllers/sign_up/passwords_controller.rb b/app/controllers/sign_up/passwords_controller.rb index a5c73987b96..a2ee1b15e65 100644 --- a/app/controllers/sign_up/passwords_controller.rb +++ b/app/controllers/sign_up/passwords_controller.rb @@ -56,7 +56,6 @@ def process_successful_password_creation ).call @user.email_addresses.take.update(confirmed_at: now) - Funnel::Registration::AddPassword.call(@user.id) sign_in_and_redirect_user end diff --git a/app/forms/register_user_email_form.rb b/app/forms/register_user_email_form.rb index 9c6eafc259d..a375438425c 100644 --- a/app/forms/register_user_email_form.rb +++ b/app/forms/register_user_email_form.rb @@ -95,7 +95,6 @@ def process_successful_submission(request_id, instructions) self.success = true user.accepted_terms_at = Time.zone.now user.save! - Funnel::Registration::Create.call(user.id) SendSignUpEmailConfirmation.new(user).call( request_id: email_request_id(request_id), instructions: instructions, diff --git a/app/services/funnel/registration/add_mfa.rb b/app/services/funnel/registration/add_mfa.rb index 8246c52e636..8be49424caf 100644 --- a/app/services/funnel/registration/add_mfa.rb +++ b/app/services/funnel/registration/add_mfa.rb @@ -3,23 +3,11 @@ module Registration class AddMfa def self.call(user_id, mfa_method, analytics) now = Time.zone.now - funnel = RegistrationLog.find_by(user_id: user_id) - return if funnel.blank? || funnel.second_mfa.present? + funnel = RegistrationLog.where(user_id: user_id).first_or_create(submitted_at: now) + return if funnel.registered_at.present? - if funnel.first_mfa.present? - params = { - second_mfa: mfa_method, - } - else - params = { - first_mfa: mfa_method, - first_mfa_at: now, - registered_at: now, - } - analytics.user_registration_user_fully_registered(mfa_method: mfa_method) - end - - funnel.update!(params) + analytics.user_registration_user_fully_registered(mfa_method: mfa_method) + funnel.update!(registered_at: now) end end end diff --git a/app/services/funnel/registration/add_password.rb b/app/services/funnel/registration/add_password.rb deleted file mode 100644 index d136df17ee3..00000000000 --- a/app/services/funnel/registration/add_password.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Funnel - module Registration - class AddPassword - # rubocop:disable Rails/SkipsModelValidations - def self.call(user_id) - RegistrationLog.where(user_id: user_id).update_all(password_at: Time.zone.now) - end - # rubocop:enable Rails/SkipsModelValidations - end - end -end diff --git a/app/services/funnel/registration/confirm_email.rb b/app/services/funnel/registration/confirm_email.rb deleted file mode 100644 index d287fd284a6..00000000000 --- a/app/services/funnel/registration/confirm_email.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Funnel - module Registration - class ConfirmEmail - # rubocop:disable Rails/SkipsModelValidations - def self.call(user_id) - RegistrationLog.where(user_id: user_id).update_all(confirmed_at: Time.zone.now) - end - # rubocop:enable Rails/SkipsModelValidations - end - end -end diff --git a/app/services/funnel/registration/create.rb b/app/services/funnel/registration/create.rb deleted file mode 100644 index 6ae8ba3dca3..00000000000 --- a/app/services/funnel/registration/create.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Funnel - module Registration - class Create - def self.call(user_id) - user = User.find(user_id) - return unless user - RegistrationLog.create(user_id: user_id, submitted_at: user.created_at) - end - end - end -end diff --git a/app/services/funnel/registration/range_submitted_count.rb b/app/services/funnel/registration/range_submitted_count.rb deleted file mode 100644 index acdbef32ca8..00000000000 --- a/app/services/funnel/registration/range_submitted_count.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Funnel - module Registration - class RangeSubmittedCount - def self.call(start, finish) - RegistrationLog.where('? < submitted_at AND submitted_at < ?', start, finish).count - end - end - end -end diff --git a/app/services/funnel/registration/total_submitted_count.rb b/app/services/funnel/registration/total_submitted_count.rb deleted file mode 100644 index dff10d6df5e..00000000000 --- a/app/services/funnel/registration/total_submitted_count.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Funnel - module Registration - class TotalSubmittedCount - def self.call - RegistrationLog.count - end - end - end -end diff --git a/spec/controllers/users/backup_code_setup_controller_spec.rb b/spec/controllers/users/backup_code_setup_controller_spec.rb index 585f7d56af3..9c1b6be6b8a 100644 --- a/spec/controllers/users/backup_code_setup_controller_spec.rb +++ b/spec/controllers/users/backup_code_setup_controller_spec.rb @@ -2,11 +2,12 @@ describe Users::BackupCodeSetupController do it 'creates backup codes and logs expected events' do - user = build(:user, :signed_up) + user = create(:user, :signed_up) stub_sign_in(user) - stub_analytics + analytics = stub_analytics stub_attempts_tracker + Funnel::Registration::AddMfa.call(user.id, 'phone', analytics) expect(PushNotification::HttpPush).to receive(:deliver). with(PushNotification::RecoveryInformationChangedEvent.new(user: user)) expect(@analytics).to receive(:track_event). diff --git a/spec/controllers/users/webauthn_setup_controller_spec.rb b/spec/controllers/users/webauthn_setup_controller_spec.rb index c5b85d9ef3a..388d6d53b6c 100644 --- a/spec/controllers/users/webauthn_setup_controller_spec.rb +++ b/spec/controllers/users/webauthn_setup_controller_spec.rb @@ -76,6 +76,7 @@ end it 'tracks the submission' do + Funnel::Registration::AddMfa.call(user.id, 'phone', @analytics) result = { enabled_mfa_methods_count: 3, mfa_method_counts: { @@ -196,6 +197,7 @@ } end it 'should log expected events' do + Funnel::Registration::AddMfa.call(user.id, 'phone', @analytics) expect(@analytics).to receive(:track_event).with( 'Multi-Factor Authentication Setup', { @@ -277,10 +279,7 @@ :mfa_enroll_webauthn_platform, success: true ) - registration_log = Funnel::Registration::Create.call(user.id) patch :confirm, params: params - - expect(registration_log.reload.first_mfa).to eq 'webauthn_platform' end end diff --git a/spec/features/visitors/sign_up_with_email_spec.rb b/spec/features/visitors/sign_up_with_email_spec.rb index 02a9f046ac0..c15a8108f45 100644 --- a/spec/features/visitors/sign_up_with_email_spec.rb +++ b/spec/features/visitors/sign_up_with_email_spec.rb @@ -8,7 +8,6 @@ expect(page).to have_content t('notices.signed_up_but_unconfirmed.first_paragraph_start') expect(page).to have_content t('notices.signed_up_but_unconfirmed.first_paragraph_end') expect(page).to have_content email - expect(Funnel::Registration::TotalSubmittedCount.call).to eq(1) expect(Funnel::Registration::TotalRegisteredCount.call).to eq(0) end @@ -54,7 +53,6 @@ visit sign_up_email_path sign_up_and_2fa_ial1_user - expect(Funnel::Registration::TotalSubmittedCount.call).to eq(1) expect(Funnel::Registration::TotalRegisteredCount.call).to eq(1) expect(current_path).to eq account_path end diff --git a/spec/services/funnel/registration/add_mfa_spec.rb b/spec/services/funnel/registration/add_mfa_spec.rb index 375a3a596c0..4bdd14b5331 100644 --- a/spec/services/funnel/registration/add_mfa_spec.rb +++ b/spec/services/funnel/registration/add_mfa_spec.rb @@ -6,34 +6,17 @@ let(:user_id) do user = create(:user) - user_id = user.id - Funnel::Registration::Create.call(user_id) - user_id + user.id end let(:funnel) { RegistrationLog.all.first } - it 'adds an 1st mfa' do - subject.call(user_id, 'phone', analytics) - - expect(funnel.first_mfa).to eq('phone') - expect(funnel.first_mfa_at).to be_present - end - - it 'adds a 2nd mfa' do - subject.call(user_id, 'phone', analytics) - subject.call(user_id, 'backup_codes', analytics) - - expect(funnel.first_mfa).to eq('phone') - expect(funnel.first_mfa_at).to be_present - expect(funnel.second_mfa).to eq('backup_codes') + it 'shows user is not fully registered with no mfa' do + expect(funnel&.registered_at).to_not be_present end - it 'does not add a 3rd mfa' do + it 'shows user is fully registered after adding an mfa' do subject.call(user_id, 'phone', analytics) - subject.call(user_id, 'backup_codes', analytics) - subject.call(user_id, 'auth_app', analytics) - expect(funnel.first_mfa).to eq('phone') - expect(funnel.second_mfa).to eq('backup_codes') + expect(funnel.registered_at).to be_present end end diff --git a/spec/services/funnel/registration/add_password_spec.rb b/spec/services/funnel/registration/add_password_spec.rb deleted file mode 100644 index 77ce021ef13..00000000000 --- a/spec/services/funnel/registration/add_password_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -describe Funnel::Registration::AddPassword do - subject { described_class } - - it 'sets the password_at' do - user = create(:user) - user_id = user.id - Funnel::Registration::Create.call(user_id) - - expect(funnel.password_at).to be_nil - - subject.call(user_id) - expect(funnel.password_at).to be_present - end - - def funnel - RegistrationLog.all.first - end -end diff --git a/spec/services/funnel/registration/confirm_email_spec.rb b/spec/services/funnel/registration/confirm_email_spec.rb deleted file mode 100644 index 4ec5a4aa3f6..00000000000 --- a/spec/services/funnel/registration/confirm_email_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -describe Funnel::Registration::ConfirmEmail do - subject { described_class } - - it 'sets the confirmed_at' do - user = create(:user) - user_id = user.id - Funnel::Registration::Create.call(user_id) - - expect(funnel.confirmed_at).to be_nil - - subject.call(user_id) - expect(funnel.confirmed_at).to be_present - end - - def funnel - RegistrationLog.all.first - end -end diff --git a/spec/services/funnel/registration/range_registered_count_spec.rb b/spec/services/funnel/registration/range_registered_count_spec.rb index 259f473a8ed..271fb357b69 100644 --- a/spec/services/funnel/registration/range_registered_count_spec.rb +++ b/spec/services/funnel/registration/range_registered_count_spec.rb @@ -52,8 +52,6 @@ def register_user(year, month, day) travel_to Date.new(year, month, day) do user = create(:user) user_id = user.id - Funnel::Registration::Create.call(user_id) - Funnel::Registration::AddPassword.call(user_id) Funnel::Registration::AddMfa.call(user_id, 'backup_codes', analytics) end end diff --git a/spec/services/funnel/registration/range_submitted_count_spec.rb b/spec/services/funnel/registration/range_submitted_count_spec.rb deleted file mode 100644 index 44b25fa2309..00000000000 --- a/spec/services/funnel/registration/range_submitted_count_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'rails_helper' - -describe Funnel::Registration::RangeSubmittedCount do - subject { described_class } - - let(:start) { '2019-01-01 00:00:00' } - let(:finish) { '2019-12-31 23:59:50' } - - it 'returns 0 when there are no records' do - expect(subject.call(start, finish)).to eq(0) - end - - it 'returns 1 when the record is mid range' do - submit_user(2019, 6, 1) - - expect(subject.call(start, finish)).to eq(1) - end - - it 'returns 1 when the record is in same month is upper range' do - submit_user(2019, 12, 30) - - expect(subject.call(start, finish)).to eq(1) - end - - it 'returns 1 when the record is in same month is lower range' do - submit_user(2019, 1, 2) - - expect(subject.call(start, finish)).to eq(1) - end - - it 'returns 0 when the record is lower than lower range' do - submit_user(2018, 12, 31) - - expect(subject.call(start, finish)).to eq(0) - end - - it 'returns 0 when the record is higher than higher range' do - submit_user(2020, 1, 2) - - expect(subject.call(start, finish)).to eq(0) - end - - it 'returns 2 when 2 records are in range' do - submit_user(2019, 1, 2) - submit_user(2019, 12, 30) - - expect(subject.call(start, finish)).to eq(2) - end - - def submit_user(year, month, day) - travel_to Date.new(year, month, day) do - user = create(:user) - user_id = user.id - Funnel::Registration::Create.call(user_id) - end - end -end diff --git a/spec/services/funnel/registration/total_registered_count_spec.rb b/spec/services/funnel/registration/total_registered_count_spec.rb index 03641f68a88..89c8e13578b 100644 --- a/spec/services/funnel/registration/total_registered_count_spec.rb +++ b/spec/services/funnel/registration/total_registered_count_spec.rb @@ -11,12 +11,8 @@ it 'returns 0 until the user is fully registered' do user = create(:user) user_id = user.id - Funnel::Registration::Create.call(user_id) - expect(Funnel::Registration::TotalRegisteredCount.call).to eq(0) - Funnel::Registration::AddPassword.call(user_id) - expect(Funnel::Registration::TotalRegisteredCount.call).to eq(0) Funnel::Registration::AddMfa.call(user_id, 'phone', analytics) @@ -40,8 +36,6 @@ def register_user user = create(:user) user_id = user.id - Funnel::Registration::Create.call(user_id) - Funnel::Registration::AddPassword.call(user_id) Funnel::Registration::AddMfa.call(user_id, 'backup_codes', analytics) end end diff --git a/spec/services/funnel/registration/total_submitted_count_spec.rb b/spec/services/funnel/registration/total_submitted_count_spec.rb deleted file mode 100644 index 43f750d1567..00000000000 --- a/spec/services/funnel/registration/total_submitted_count_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -describe Funnel::Registration::TotalSubmittedCount do - subject { described_class } - - it 'returns 0' do - expect(subject.call).to eq(0) - end - - it 'returns 1' do - user = create(:user) - Funnel::Registration::Create.call(user.id) - - expect(subject.call).to eq(1) - end - - it 'returns 2' do - Funnel::Registration::Create.call(create(:user).id) - Funnel::Registration::Create.call(create(:user).id) - - expect(subject.call).to eq(2) - end -end diff --git a/spec/services/request_password_reset_spec.rb b/spec/services/request_password_reset_spec.rb index 6bf0ded0f38..ce8e5ea7120 100644 --- a/spec/services/request_password_reset_spec.rb +++ b/spec/services/request_password_reset_spec.rb @@ -39,7 +39,6 @@ ).perform user = User.find_with_email(email) expect(user).to be_present - expect(RegistrationLog.first.user_id).to eq(user.id) end end diff --git a/spec/support/features/session_helper.rb b/spec/support/features/session_helper.rb index d7b32dd23ba..4268edfb26c 100644 --- a/spec/support/features/session_helper.rb +++ b/spec/support/features/session_helper.rb @@ -129,7 +129,6 @@ def fill_in_password_and_submit(password) def sign_up user = create(:user, :unconfirmed) - Funnel::Registration::Create.call(user.id) confirm_last_user user end