diff --git a/app/controllers/concerns/two_factor_authenticatable_methods.rb b/app/controllers/concerns/two_factor_authenticatable_methods.rb index 92bd9e797b2..fb67d45c663 100644 --- a/app/controllers/concerns/two_factor_authenticatable_methods.rb +++ b/app/controllers/concerns/two_factor_authenticatable_methods.rb @@ -170,18 +170,10 @@ def update_invalid_user def handle_valid_verification_for_confirmation_context user_session[:authn_at] = Time.zone.now - track_mfa_method_added @next_mfa_setup_path = next_setup_path reset_second_factor_attempts_count end - def track_mfa_method_added - mfa_user = MfaContext.new(current_user) - mfa_count = mfa_user.enabled_mfa_methods_count - analytics.multi_factor_auth_added_phone(enabled_mfa_methods_count: mfa_count) - Funnel::Registration::AddMfa.call(current_user.id, 'phone', analytics) - end - def handle_valid_otp_for_authentication_context(auth_method:) user_session[:auth_method] = auth_method mark_user_session_authenticated(:valid_2fa) diff --git a/app/controllers/two_factor_authentication/otp_verification_controller.rb b/app/controllers/two_factor_authentication/otp_verification_controller.rb index 429f3e6e5fd..066e03d9cc7 100644 --- a/app/controllers/two_factor_authentication/otp_verification_controller.rb +++ b/app/controllers/two_factor_authentication/otp_verification_controller.rb @@ -32,6 +32,7 @@ def create def handle_valid_confirmation_otp assign_phone + track_mfa_added flash[:success] = t('notices.phone_confirmed') end @@ -46,6 +47,13 @@ def redirect_if_blank_phone redirect_to new_user_session_path end + def track_mfa_added + analytics.multi_factor_auth_added_phone( + enabled_mfa_methods_count: MfaContext.new(current_user).enabled_mfa_methods_count, + ) + Funnel::Registration::AddMfa.call(current_user.id, 'phone', analytics) + end + def confirm_multiple_factors_enabled return if UserSessionContext.confirmation_context?(context) phone_enabled = phone_enabled?