Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FormResponse#to_hash to support implicit hash conversion #11476

Merged
merged 4 commits into from
Nov 7, 2024
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
4 changes: 2 additions & 2 deletions app/controllers/account_reset/cancel_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def show
return render :show unless token

result = AccountReset::ValidateCancelToken.new(token).call
analytics.account_reset_cancel_token_validation(**result.to_h)
analytics.account_reset_cancel_token_validation(**result)

if result.success?
handle_valid_token
Expand All @@ -18,7 +18,7 @@ def show
def create
result = AccountReset::Cancel.new(session[:cancel_token]).call

analytics.account_reset_cancel(**result.to_h)
analytics.account_reset_cancel(**result)

if result.success?
handle_success
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/account_reset/delete_account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def show
render :show and return unless token

result = AccountReset::ValidateGrantedToken.new(token, request, analytics).call
analytics.account_reset_granted_token_validation(**result.to_h)
analytics.account_reset_granted_token_validation(**result)

if result.success?
handle_valid_token
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/account_reset/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create

def create_account_reset_request
response = AccountReset::CreateRequest.new(current_user, sp_session[:issuer]).call
analytics.account_reset_request(**response.to_h, **analytics_attributes)
analytics.account_reset_request(**response, **analytics_attributes)
end

def confirm_two_factor_enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def update

result = @select_email_form.submit(form_params)

analytics.sp_select_email_submitted(**result.to_h)
analytics.sp_select_email_submitted(**result)

if result.success?
flash[:email_updated_identity_id] = identity.id
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/accounts/personal_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create
analytics.profile_personal_key_create
create_user_event(:new_personal_key)
result = send_new_personal_key_notifications
analytics.profile_personal_key_create_notifications(**result.to_h)
analytics.profile_personal_key_create_notifications(**result)

flash[:info] = t('account.personal_key.old_key_will_not_work')
redirect_to manage_personal_key_url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def update
configuration_id: params[:id],
).submit(name: params[:name])

analytics.auth_app_update_name_submitted(**result.to_h)
analytics.auth_app_update_name_submitted(**result)

if result.success?
render json: { success: true }
Expand All @@ -34,7 +34,7 @@ def destroy
configuration_id: params[:id],
).submit

analytics.auth_app_delete_submitted(**result.to_h)
analytics.auth_app_delete_submitted(**result)

if result.success?
create_user_event(:authenticator_disabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def update
configuration_id: params[:id],
).submit(name: params[:name])

analytics.piv_cac_update_name_submitted(**result.to_h)
analytics.piv_cac_update_name_submitted(**result)

if result.success?
render json: { success: true }
Expand All @@ -35,7 +35,7 @@ def destroy
configuration_id: params[:id],
).submit

analytics.piv_cac_delete_submitted(**result.to_h)
analytics.piv_cac_delete_submitted(**result)

if result.success?
create_user_event(:piv_cac_disabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def update
configuration_id: params[:id],
).submit(name: params[:name])

analytics.webauthn_update_name_submitted(**result.to_h)
analytics.webauthn_update_name_submitted(**result)

if result.success?
render json: { success: true }
Expand All @@ -34,7 +34,7 @@ def destroy
configuration_id: params[:id],
).submit

analytics.webauthn_delete_submitted(**result.to_h)
analytics.webauthn_delete_submitted(**result)

if result.success?
create_user_event(:webauthn_key_removed)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/idv/verify_info_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def async_state_done(current_async_state)
flash[:success] = t('doc_auth.forms.doc_success')
redirect_to next_step_url
end
analytics.idv_doc_auth_verify_proofing_results(**analytics_arguments, **form_response.to_h)
analytics.idv_doc_auth_verify_proofing_results(**analytics_arguments, **form_response)
end

def next_step_url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def auth_methods_session
def handle_verification_for_authentication_context(result:, auth_method:, extra_analytics: nil)
increment_mfa_selection_attempt_count(auth_method)
analytics.multi_factor_auth(
**result.to_h,
**result,
multi_factor_auth_method: auth_method,
enabled_mfa_methods_count: mfa_context.enabled_mfa_methods_count,
new_device: new_device?,
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/event_disavowal_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def new
success: true,
extra: EventDisavowal::BuildDisavowedEventAnalyticsAttributes.call(disavowed_event),
)
analytics.event_disavowal(**result.to_h)
analytics.event_disavowal(**result)
@forbidden_passwords = forbidden_passwords
end

def create
result = password_reset_from_disavowal_form.submit(password_reset_params)
analytics.event_disavowal_password_reset(**result.to_h)
analytics.event_disavowal_password_reset(**result)
if result.success?
handle_successful_password_reset
else
Expand Down Expand Up @@ -50,7 +50,7 @@ def validate_disavowed_event
return
end

analytics.event_disavowal_token_invalid(**result.to_h)
analytics.event_disavowal_token_invalid(**result)
flash[:error] = (result.errors[:event] || result.errors.first.last).first
redirect_to root_url
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/by_mail/enter_code_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def create
@gpo_verify_form = build_gpo_verify_form

result = @gpo_verify_form.submit(resolved_authn_context_result.enhanced_ipp?)
analytics.idv_verify_by_mail_enter_code_submitted(**result.to_h)
analytics.idv_verify_by_mail_enter_code_submitted(**result)

if !result.success?
if rate_limiter.limited?
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/in_person/address_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def update
form_result = form.submit(flow_params)

analytics.idv_in_person_proofing_residential_address_submitted(
**analytics_arguments.merge(**form_result.to_h),
**analytics_arguments.merge(**form_result),
)

if form_result.success?
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/in_person/state_id_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def update
end

analytics.idv_in_person_proofing_state_id_submitted(
**analytics_arguments.merge(**form_result.to_h),
**analytics_arguments.merge(**form_result),
)
# Accept Date of Birth from both memorable date and input date components
formatted_dob = MemorableDateComponent.extract_date_param flow_params&.[](:dob)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/otp_verification_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def show
def update
clear_future_steps!
result = phone_confirmation_otp_verification_form.submit(code: params[:code])
analytics.idv_phone_confirmation_otp_submitted(**result.to_h, **ab_test_analytics_buckets)
analytics.idv_phone_confirmation_otp_submitted(**result, **ab_test_analytics_buckets)

if result.success?
idv_session.mark_phone_step_complete!
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/phone_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def create
Funnel::DocAuth::RegisterStep.new(current_user.id, current_sp&.issuer).
call(:verify_phone, :update, result.success?)

analytics.idv_phone_confirmation_form_submitted(**result.to_h, **ab_test_analytics_buckets)
analytics.idv_phone_confirmation_form_submitted(**result, **ab_test_analytics_buckets)
if result.success?
submit_proofing_attempt
redirect_to idv_phone_path
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/idv/resend_otp_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ResendOtpController < ApplicationController

def create
result = send_phone_confirmation_otp
analytics.idv_phone_confirmation_otp_resent(**result.to_h)
analytics.idv_phone_confirmation_otp_resent(**result)
if result.success?
redirect_to idv_otp_verification_url
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/openid_connect/user_info_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def show
def authenticate_identity_via_bearer_token
verifier = AccessTokenVerifier.new(request.env['HTTP_AUTHORIZATION'])
response, identity = verifier.submit
analytics.openid_connect_bearer_token(**response.to_h)
analytics.openid_connect_bearer_token(**response)

if response.success?
@current_identity = identity
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/risc/security_events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create
form = SecurityEventForm.new(body: request.body.read)
result = form.submit

analytics.security_event_received(**result.to_h)
analytics.security_event_received(**result)

if result.success?
head :accepted
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/sign_up/email_confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def create
private

def log_validator_result
analytics.user_registration_email_confirmation(
**email_confirmation_token_validator_result.to_h,
)
analytics.user_registration_email_confirmation(**email_confirmation_token_validator_result)
end

def clear_setup_piv_cac_from_sign_in
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sign_up/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def render_page
end

def track_analytics(result)
analytics.password_creation(**result.to_h)
analytics.password_creation(**result)
end

def permitted_params
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sign_up/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create

result = @register_user_email_form.submit(permitted_params.merge(request_id:))

analytics.user_registration_email(**result.to_h)
analytics.user_registration_email(**result)

if result.success?
process_successful_creation
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sign_up/select_email_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create

result = @select_email_form.submit(form_params)

analytics.sp_select_email_submitted(**result.to_h, needs_completion_screen_reason:)
analytics.sp_select_email_submitted(**result, needs_completion_screen_reason:)

if result.success?
user_session[:selected_email_id_for_linked_identity] = form_params[:selected_email_id]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def index
def create
@two_factor_options_form = TwoFactorLoginOptionsForm.new(current_user)
result = @two_factor_options_form.submit(two_factor_options_form_params)
analytics.multi_factor_auth_option_list(**result.to_h)
analytics.multi_factor_auth_option_list(**result)

if result.success?
process_valid_form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def handle_result(result)

def alert_user_about_personal_key_sign_in(disavowal_token)
response = UserAlerts::AlertUserAboutPersonalKeySignIn.call(current_user, disavowal_token)
analytics.personal_key_alert_about_sign_in(**response.to_h)
analytics.personal_key_alert_about_sign_in(**response)
end

def remove_personal_key
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users/auth_app_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def edit; end
def update
result = form.submit(name: params.dig(:form, :name))

analytics.auth_app_update_name_submitted(**result.to_h)
analytics.auth_app_update_name_submitted(**result)

if result.success?
flash[:success] = t('two_factor_authentication.auth_app.renamed')
Expand All @@ -28,7 +28,7 @@ def update
def destroy
result = form.submit

analytics.auth_app_delete_submitted(**result.to_h)
analytics.auth_app_delete_submitted(**result)

if result.success?
flash[:success] = t('two_factor_authentication.auth_app.deleted')
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/edit_phone_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def edit
def update
@edit_phone_form = EditPhoneForm.new(current_user, phone_configuration)
result = @edit_phone_form.submit(edit_phone_params)
analytics.phone_change_submitted(**result.to_h)
analytics.phone_change_submitted(**result)
if result.success?
redirect_to account_url
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/email_confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Users
class EmailConfirmationsController < ApplicationController
def create
result = email_confirmation_token_validator.submit
analytics.add_email_confirmation(**result.to_h)
analytics.add_email_confirmation(**result)
if result.success?
process_successful_confirmation(email_address)
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/email_language_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def show

def update
form_response = UpdateEmailLanguageForm.new(current_user).submit(update_email_params)
analytics.email_language_updated(**form_response.to_h)
analytics.email_language_updated(**form_response)

flash[:success] = I18n.t('account.email_language.updated') if form_response.success?

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users/emails_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def add
result = @add_user_email_form.submit(
current_user, permitted_params
)
analytics.add_email_request(**result.to_h)
analytics.add_email_request(**result)

if result.success?
process_successful_creation
Expand Down Expand Up @@ -58,7 +58,7 @@ def confirm_delete

def delete
result = DeleteUserEmailForm.new(current_user, email_address).submit
analytics.email_deletion_request(**result.to_h)
analytics.email_deletion_request(**result)
if result.success?
handle_successful_delete
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def update

result = @update_user_password_form.submit(user_password_params)

analytics.password_changed(**result.to_h)
analytics.password_changed(**result)

if result.success?
handle_valid_password
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/phone_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def index
def create
@new_phone_form = NewPhoneForm.new(user: current_user, analytics: analytics)
result = @new_phone_form.submit(new_phone_form_params)
analytics.multi_factor_auth_phone_setup(**result.to_h)
analytics.multi_factor_auth_phone_setup(**result)

if result.success?
handle_create_success(@new_phone_form.phone)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users/piv_cac_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def edit; end
def update
result = form.submit(name: params.dig(:form, :name))

analytics.piv_cac_update_name_submitted(**result.to_h)
analytics.piv_cac_update_name_submitted(**result)

if result.success?
flash[:success] = presenter.rename_success_alert_text
Expand All @@ -30,7 +30,7 @@ def update
def destroy
result = form.submit

analytics.piv_cac_delete_submitted(**result.to_h)
analytics.piv_cac_delete_submitted(**result)

if result.success?
create_user_event(:piv_cac_disabled)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/piv_cac_login_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def process_piv_cac_login
else
process_invalid_submission
end
analytics.piv_cac_login(**result.to_h, new_device: @new_device)
analytics.piv_cac_login(**result, new_device: @new_device)
end

def piv_cac_login_form
Expand Down
Loading