From 71afd96bac1920e7310fc263ca6df671e9bc9d10 Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Thu, 6 May 2021 22:32:57 -0500 Subject: [PATCH 01/32] LG-4449 Implement rules of use for existing users --- app/controllers/rules_of_use_controller.rb | 49 +++++++++++++++++++ app/controllers/users/sessions_controller.rb | 10 +++- app/forms/rules_of_use_form.rb | 50 ++++++++++++++++++++ app/javascript/packs/form-validation.js | 19 +++++--- app/models/user.rb | 4 ++ app/services/analytics.rb | 1 + app/views/rules_of_use/new.html.erb | 38 +++++++++++++++ config/locales/errors/en.yml | 1 + config/locales/errors/es.yml | 1 + config/locales/errors/fr.yml | 1 + config/locales/users/en.yml | 11 +++++ config/locales/users/es.yml | 5 ++ config/locales/users/fr.yml | 5 ++ config/routes.rb | 3 ++ spec/factories/users.rb | 3 ++ 15 files changed, 193 insertions(+), 8 deletions(-) create mode 100644 app/controllers/rules_of_use_controller.rb create mode 100644 app/forms/rules_of_use_form.rb create mode 100644 app/views/rules_of_use/new.html.erb diff --git a/app/controllers/rules_of_use_controller.rb b/app/controllers/rules_of_use_controller.rb new file mode 100644 index 00000000000..eaa4174ae9e --- /dev/null +++ b/app/controllers/rules_of_use_controller.rb @@ -0,0 +1,49 @@ +class RulesOfUseController < ApplicationController + before_action :confirm_signed_in + before_action :confirm_need_to_accept_rules_of_use + + def new + analytics.track_event(Analytics::RULES_OF_USE_VISIT) + @rules_of_use_form = new_rules_of_use_form + render :new, locals: { request_id: nil }, formats: :html + end + + def create + @rules_of_use_form = new_rules_of_use_form + + result = @rules_of_use_form.submit(permitted_params) + + analytics.track_event(Analytics::USER_REGISTRATION_EMAIL, result.to_h) + + if result.success? + process_successful_agreement_to_rules_of_use + else + render :new + end + end + + private + + def new_rules_of_use_form + RulesOfUseForm.new(user: current_user, analytics: analytics) + end + + def process_successful_agreement_to_rules_of_use + redirect_to user_two_factor_authentication_url + end + + def confirm_signed_in + return if signed_in? + redirect_to root_url + end + + def confirm_need_to_accept_rules_of_use + return unless current_user.accepted_terms_at + + redirect_to user_two_factor_authentication_url + end + + def permitted_params + params.require(:user).permit(:terms_accepted) + end +end diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index d8415a5f826..8dcbefd68c9 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -174,10 +174,16 @@ def request_id end def redirect_to_2fa_or_pending_reset + redirect_to next_url + end + + def next_url if pending_account_reset_request.present? - redirect_to account_reset_pending_url + account_reset_pending_url + elsif current_user.accepted_rules_of_use? + user_two_factor_authentication_url else - redirect_to user_two_factor_authentication_url + rules_of_use_url end end diff --git a/app/forms/rules_of_use_form.rb b/app/forms/rules_of_use_form.rb new file mode 100644 index 00000000000..0fb13e1c8c1 --- /dev/null +++ b/app/forms/rules_of_use_form.rb @@ -0,0 +1,50 @@ +class RulesOfUseForm + include ActiveModel::Model + include ActionView::Helpers::TranslationHelper + + validate :validate_terms_accepted + + attr_reader :terms_accepted + + def self.model_name + ActiveModel::Name.new(self, nil, 'User') + end + + def initialize(user:, analytics:) + @user = user + @analytics = analytics + end + + def validate_terms_accepted + return if @terms_accepted + + errors.add(:terms_accepted, t('errors.registration.terms')) + end + + def submit(params, instructions = nil) + @terms_accepted = params[:terms_accepted] == 'true' + if valid? + process_successful_submission + else + self.success = false + end + + FormResponse.new(success: success, errors: errors.messages, extra: extra_analytics_attributes) + end + + private + + attr_accessor :success, :user + + def process_successful_submission + self.success = true + user.accepted_terms_at = Time.zone.now + user.save! + end + + def extra_analytics_attributes + { + user_id: user.uuid, + } + end +end diff --git a/app/javascript/packs/form-validation.js b/app/javascript/packs/form-validation.js index 0a3fd242d26..618481f9147 100644 --- a/app/javascript/packs/form-validation.js +++ b/app/javascript/packs/form-validation.js @@ -18,12 +18,9 @@ function disableFormSubmit(event) { } /** - * Given an `input` or `invalid` event, updates custom validity of the given input. - * - * @param {Event} event Input or invalid event. + * @param {HTMLInputElement} input */ -function checkInputValidity(event) { - const input = /** @type {HTMLInputElement} */ (event.target); +function validateInput(input) { input.setCustomValidity(''); input.setAttribute('aria-invalid', String(!input.validity.valid)); if ( @@ -52,12 +49,22 @@ function checkInputValidity(event) { } } +/** + * Given an `input` or `invalid` event, updates custom validity of the given input. + * + * @param {Event} event Input or invalid event. + */ +function checkInputValidity(event) { + const input = /** @type {HTMLInputElement} */ (event.target); + validateInput(input); +} + /** * Binds validation to a given input. * * @param {HTMLInputElement} input Input element. */ -function validateInput(input) { +function addInputValidationListeners(input) { input.addEventListener('input', checkInputValidity); input.addEventListener('invalid', checkInputValidity); } diff --git a/app/models/user.rb b/app/models/user.rb index 49a3eec7f75..dfb61073161 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -64,6 +64,10 @@ def confirmed? email_addresses.where.not(confirmed_at: nil).any? end + def accepted_rules_of_use? + self.accepted_terms_at.present? + end + def set_reset_password_token super end diff --git a/app/services/analytics.rb b/app/services/analytics.rb index 3b6815fd47e..a0187672387 100644 --- a/app/services/analytics.rb +++ b/app/services/analytics.rb @@ -177,6 +177,7 @@ def browser_attributes REMEMBERED_DEVICE_USED_FOR_AUTH = 'Remembered device used for authentication'.freeze RETURN_TO_SP_CANCEL = 'Return to SP: Cancelled'.freeze RETURN_TO_SP_FAILURE_TO_PROOF = 'Return to SP: Failed to proof'.freeze + RULES_OF_USE_VISIT = 'Rules Of Use Visited'.freeze SECURITY_EVENT_RECEIVED = 'RISC: Security event received'.freeze SP_REVOKE_CONSENT_REVOKED = 'SP Revoke Consent: Revoked'.freeze SP_REVOKE_CONSENT_VISITED = 'SP Revoke Consent: Visited'.freeze diff --git a/app/views/rules_of_use/new.html.erb b/app/views/rules_of_use/new.html.erb new file mode 100644 index 00000000000..ff328c2001a --- /dev/null +++ b/app/views/rules_of_use/new.html.erb @@ -0,0 +1,38 @@ +<% title t('titles.registrations.new') %> + +

<%= t('titles.rules_of_use') %>

+ +

+<%== t('users.rules_of_use.overview', link: new_window_link_to(t('titles.rules_of_use'), + "http://localhost:4000/policy/rules-of-use/")) %> +

+ +<%= t('users.rules_of_use.details_html') %> +
+ <%= validated_form_for(@rules_of_use_form, + html: { autocomplete: 'off', role: 'form' }, + url: rules_of_use_path) do |f| %> + +
+ <%= f.check_box :terms_accepted, { class: 'usa-checkbox__input', + required: true, aria: { invalid: false } }, true, false %> + + +
+ + <%= f.input :request_id, as: :hidden, input_html: { value: params[:request_id] || request_id } %> + <%= f.button :button, t('forms.buttons.continue'), type: :submit, + class: 'usa-button--big grid-col-8 mobile-lg:grid-col-6' %> +<% end %> +
+ +<%= render 'shared/cancel', link: decorated_session.cancel_link_url %> + +

+

+ +<%= javascript_packs_tag_once 'accept-terms-button' %> diff --git a/config/locales/errors/en.yml b/config/locales/errors/en.yml index 9e4d96ea6b2..534ba7be711 100644 --- a/config/locales/errors/en.yml +++ b/config/locales/errors/en.yml @@ -103,6 +103,7 @@ en: registration: terms: Before you can continue, you must give us permission. Please check the box below and then click continue. + rules_of_use: Please check this box to continue two_factor_auth_setup: must_select_option: Select an authentication method. verify_personal_key: diff --git a/config/locales/errors/es.yml b/config/locales/errors/es.yml index b3bfa19ed09..48631fd4e34 100644 --- a/config/locales/errors/es.yml +++ b/config/locales/errors/es.yml @@ -107,6 +107,7 @@ es: registration: terms: Antes de continuar, debe darnos permiso. Marque la casilla a continuación y luego haga clic en continuar. + rules_of_use: Marque esta casilla para continuar two_factor_auth_setup: must_select_option: Seleccione un método de autenticación. verify_personal_key: diff --git a/config/locales/errors/fr.yml b/config/locales/errors/fr.yml index 83ea6e447e3..a7140d77fb2 100644 --- a/config/locales/errors/fr.yml +++ b/config/locales/errors/fr.yml @@ -116,6 +116,7 @@ fr: registration: terms: Avant de pouvoir continuer, vous devez nous donner la permission. Veuillez cocher la case ci-dessous puis cliquez sur continuer. + rules_of_use: Veuillez cocher cette case pour continuer two_factor_auth_setup: must_select_option: Sélectionnez une méthode d’authentification. verify_personal_key: diff --git a/config/locales/users/en.yml b/config/locales/users/en.yml index 262c194072d..13669338817 100644 --- a/config/locales/users/en.yml +++ b/config/locales/users/en.yml @@ -24,3 +24,14 @@ en: generated_on_html: Generated on %{date} header: Your personal key print: Print + rules_of_use: + check_box_to_accept: Check this box to accept the login.gov + details_html: |- +
Rules of Use:
+ + overview: We've updated our %{link}. Please review and check the box below to continue. diff --git a/config/locales/users/es.yml b/config/locales/users/es.yml index 88c4fe6263d..8273f7d7615 100644 --- a/config/locales/users/es.yml +++ b/config/locales/users/es.yml @@ -25,3 +25,8 @@ es: generated_on_html: Generado el %{date} header: Su clave personal print: Imprima esta página + rules_of_use: + check_box_to_accept: translate + details_html: |- + translate + overview: translate diff --git a/config/locales/users/fr.yml b/config/locales/users/fr.yml index 7bbe3aefb51..b8a8c233ef4 100644 --- a/config/locales/users/fr.yml +++ b/config/locales/users/fr.yml @@ -27,3 +27,8 @@ fr: generated_on_html: Générée le %{date} header: Votre clé personnelle print: Imprimer cette page + rules_of_use: + check_box_to_accept: translate + details_html: |- + translate + overview: translate diff --git a/config/routes.rb b/config/routes.rb index 66e9d5861be..7e44aa8a782 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -161,6 +161,9 @@ get '/events/disavow' => 'event_disavowal#new', as: :event_disavowal post '/events/disavow' => 'event_disavowal#create', as: :events_disavowal + get '/rules_of_use' => 'rules_of_use#new' + post '/rules_of_use' => 'rules_of_use#create' + get '/piv_cac' => 'users/piv_cac_authentication_setup#new', as: :setup_piv_cac get '/piv_cac_error' => 'users/piv_cac_authentication_setup#error', as: :setup_piv_cac_error delete '/piv_cac' => 'users/piv_cac_authentication_setup#delete', as: :disable_piv_cac diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 3cf048e54cd..8059bb9e53b 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -8,6 +8,7 @@ with { {} } email { Faker::Internet.safe_email } confirmed_at { Time.zone.now } + accepted_terms_at { Time.zone.now } end after(:build) do |user, evaluator| @@ -18,6 +19,7 @@ ) user.email = evaluator.email user.confirmed_at = evaluator.confirmed_at + user.accepted_terms_at = Time.zone.now end after(:stub) do |user, evaluator| @@ -28,6 +30,7 @@ ) user.email = evaluator.email user.confirmed_at = evaluator.confirmed_at + user.accepted_terms_at = Time.zone.now end trait :with_multiple_emails do From 30114740ac16f8a180ca4573fc9ac4b030936b2e Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Thu, 6 May 2021 22:50:35 -0500 Subject: [PATCH 02/32] Misc --- app/controllers/rules_of_use_controller.rb | 2 +- app/forms/rules_of_use_form.rb | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/app/controllers/rules_of_use_controller.rb b/app/controllers/rules_of_use_controller.rb index eaa4174ae9e..b32c07619a9 100644 --- a/app/controllers/rules_of_use_controller.rb +++ b/app/controllers/rules_of_use_controller.rb @@ -25,7 +25,7 @@ def create private def new_rules_of_use_form - RulesOfUseForm.new(user: current_user, analytics: analytics) + RulesOfUseForm.new(current_user) end def process_successful_agreement_to_rules_of_use diff --git a/app/forms/rules_of_use_form.rb b/app/forms/rules_of_use_form.rb index 0fb13e1c8c1..731dbd8e5e9 100644 --- a/app/forms/rules_of_use_form.rb +++ b/app/forms/rules_of_use_form.rb @@ -10,9 +10,8 @@ def self.model_name ActiveModel::Name.new(self, nil, 'User') end - def initialize(user:, analytics:) + def initialize(user) @user = user - @analytics = analytics end def validate_terms_accepted @@ -29,7 +28,7 @@ def submit(params, instructions = nil) self.success = false end - FormResponse.new(success: success, errors: errors.messages, extra: extra_analytics_attributes) + FormResponse.new(success: success, errors: errors.messages) end private @@ -41,10 +40,4 @@ def process_successful_submission user.accepted_terms_at = Time.zone.now user.save! end - - def extra_analytics_attributes - { - user_id: user.uuid, - } - end end From bccc5f063c26c307e7c653ef8f5dbef40d2e1e1a Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Thu, 6 May 2021 23:11:06 -0500 Subject: [PATCH 03/32] Misc --- config/locales/users/en.yml | 3 ++- config/locales/users/es.yml | 3 +-- config/locales/users/fr.yml | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/config/locales/users/en.yml b/config/locales/users/en.yml index 13669338817..aa1252b023a 100644 --- a/config/locales/users/en.yml +++ b/config/locales/users/en.yml @@ -34,4 +34,5 @@ en:
  • How we use your information and your rights to that information, ands
  • The conditions you agree to when you take certain actions on the login.gov service.
  • - overview: We've updated our %{link}. Please review and check the box below to continue. + overview: We’ve updated our %{link}. Please review and check the box below to + continue. diff --git a/config/locales/users/es.yml b/config/locales/users/es.yml index 8273f7d7615..f99381d92af 100644 --- a/config/locales/users/es.yml +++ b/config/locales/users/es.yml @@ -27,6 +27,5 @@ es: print: Imprima esta página rules_of_use: check_box_to_accept: translate - details_html: |- - translate + details_html: translate overview: translate diff --git a/config/locales/users/fr.yml b/config/locales/users/fr.yml index b8a8c233ef4..35a35ecf65c 100644 --- a/config/locales/users/fr.yml +++ b/config/locales/users/fr.yml @@ -29,6 +29,5 @@ fr: print: Imprimer cette page rules_of_use: check_box_to_accept: translate - details_html: |- - translate + details_html: translate overview: translate From ee4909d526cea2399816a29b3f6d54c3519ac3d1 Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Thu, 6 May 2021 23:35:12 -0500 Subject: [PATCH 04/32] Misc --- spec/support/features/session_helper.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/support/features/session_helper.rb b/spec/support/features/session_helper.rb index 77e4756a9a9..10692cbb671 100644 --- a/spec/support/features/session_helper.rb +++ b/spec/support/features/session_helper.rb @@ -17,6 +17,8 @@ def expect_email_invalid(page) end def choose_another_security_option(option) + accept_rules_of_use_and_continue_if_displayed + click_link t('two_factor_authentication.login_options_link_text') expect(current_path).to eq login_two_factor_options_path @@ -262,9 +264,16 @@ def sign_in_live_with_piv_cac(user = user_with_piv_cac) end def fill_in_code_with_last_phone_otp + accept_rules_of_use_and_continue_if_displayed fill_in :code, with: last_phone_otp end + def accept_rules_of_use_and_continue_if_displayed + return unless current_path == rules_of_use_path + check t('users.rules_of_use.check_box_to_accept'), allow_label_click: true + click_button t('forms.buttons.continue') + end + def click_submit_default click_button t('forms.buttons.submit.default') end From 6b113cb5b70a664cdb0fd0ee8fb7a3a01e361d02 Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Thu, 6 May 2021 23:52:59 -0500 Subject: [PATCH 05/32] Misc --- app/forms/rules_of_use_form.rb | 2 +- config/locales/users/es.yml | 2 +- config/locales/users/fr.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/forms/rules_of_use_form.rb b/app/forms/rules_of_use_form.rb index 731dbd8e5e9..6b693411331 100644 --- a/app/forms/rules_of_use_form.rb +++ b/app/forms/rules_of_use_form.rb @@ -17,7 +17,7 @@ def initialize(user) def validate_terms_accepted return if @terms_accepted - errors.add(:terms_accepted, t('errors.registration.terms')) + errors.add(:terms_accepted, t('errors.rules_of_use')) end def submit(params, instructions = nil) diff --git a/config/locales/users/es.yml b/config/locales/users/es.yml index f99381d92af..2a2a07721c2 100644 --- a/config/locales/users/es.yml +++ b/config/locales/users/es.yml @@ -28,4 +28,4 @@ es: rules_of_use: check_box_to_accept: translate details_html: translate - overview: translate + overview: translate %{link} diff --git a/config/locales/users/fr.yml b/config/locales/users/fr.yml index 35a35ecf65c..4ed1537737e 100644 --- a/config/locales/users/fr.yml +++ b/config/locales/users/fr.yml @@ -30,4 +30,4 @@ fr: rules_of_use: check_box_to_accept: translate details_html: translate - overview: translate + overview: translate %{link} From c80eae2f1d9b686fdb97b0405949756c404ebb24 Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Fri, 7 May 2021 00:23:35 -0500 Subject: [PATCH 06/32] Misc --- spec/support/monitor/monitor_idp_steps.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/support/monitor/monitor_idp_steps.rb b/spec/support/monitor/monitor_idp_steps.rb index d9bbce230f6..52fc41f98da 100644 --- a/spec/support/monitor/monitor_idp_steps.rb +++ b/spec/support/monitor/monitor_idp_steps.rb @@ -57,6 +57,12 @@ def sign_in_and_2fa(email) fill_in 'user_email', with: email fill_in 'user_password', with: monitor.config.login_gov_sign_in_password click_on 'Sign in' + + if current_path == rules_of_use_path + check t('users.rules_of_use.check_box_to_accept'), allow_label_click: true + click_button t('forms.buttons.continue') + end + fill_in 'code', with: monitor.check_for_otp uncheck 'Remember this browser' click_on 'Submit' From 8e9b9a07fa7a0802ae15e1e5610dfc588050e8f0 Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Fri, 7 May 2021 11:40:20 -0500 Subject: [PATCH 07/32] Controller under users --- app/controllers/rules_of_use_controller.rb | 49 ------------------ .../users/rules_of_use_controller.rb | 51 +++++++++++++++++++ config/routes.rb | 4 +- 3 files changed, 53 insertions(+), 51 deletions(-) delete mode 100644 app/controllers/rules_of_use_controller.rb create mode 100644 app/controllers/users/rules_of_use_controller.rb diff --git a/app/controllers/rules_of_use_controller.rb b/app/controllers/rules_of_use_controller.rb deleted file mode 100644 index b32c07619a9..00000000000 --- a/app/controllers/rules_of_use_controller.rb +++ /dev/null @@ -1,49 +0,0 @@ -class RulesOfUseController < ApplicationController - before_action :confirm_signed_in - before_action :confirm_need_to_accept_rules_of_use - - def new - analytics.track_event(Analytics::RULES_OF_USE_VISIT) - @rules_of_use_form = new_rules_of_use_form - render :new, locals: { request_id: nil }, formats: :html - end - - def create - @rules_of_use_form = new_rules_of_use_form - - result = @rules_of_use_form.submit(permitted_params) - - analytics.track_event(Analytics::USER_REGISTRATION_EMAIL, result.to_h) - - if result.success? - process_successful_agreement_to_rules_of_use - else - render :new - end - end - - private - - def new_rules_of_use_form - RulesOfUseForm.new(current_user) - end - - def process_successful_agreement_to_rules_of_use - redirect_to user_two_factor_authentication_url - end - - def confirm_signed_in - return if signed_in? - redirect_to root_url - end - - def confirm_need_to_accept_rules_of_use - return unless current_user.accepted_terms_at - - redirect_to user_two_factor_authentication_url - end - - def permitted_params - params.require(:user).permit(:terms_accepted) - end -end diff --git a/app/controllers/users/rules_of_use_controller.rb b/app/controllers/users/rules_of_use_controller.rb new file mode 100644 index 00000000000..9af0b19ae04 --- /dev/null +++ b/app/controllers/users/rules_of_use_controller.rb @@ -0,0 +1,51 @@ +module Users + class RulesOfUseController < ApplicationController + before_action :confirm_signed_in + before_action :confirm_need_to_accept_rules_of_use + + def new + analytics.track_event(Analytics::RULES_OF_USE_VISIT) + @rules_of_use_form = new_rules_of_use_form + render :new, locals: { request_id: nil }, formats: :html + end + + def create + @rules_of_use_form = new_rules_of_use_form + + result = @rules_of_use_form.submit(permitted_params) + + analytics.track_event(Analytics::USER_REGISTRATION_EMAIL, result.to_h) + + if result.success? + process_successful_agreement_to_rules_of_use + else + render :new + end + end + + private + + def new_rules_of_use_form + RulesOfUseForm.new(current_user) + end + + def process_successful_agreement_to_rules_of_use + redirect_to user_two_factor_authentication_url + end + + def confirm_signed_in + return if signed_in? + redirect_to root_url + end + + def confirm_need_to_accept_rules_of_use + return unless current_user.accepted_terms_at + + redirect_to user_two_factor_authentication_url + end + + def permitted_params + params.require(:user).permit(:terms_accepted) + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 7e44aa8a782..d4b8ea5de6c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -161,8 +161,8 @@ get '/events/disavow' => 'event_disavowal#new', as: :event_disavowal post '/events/disavow' => 'event_disavowal#create', as: :events_disavowal - get '/rules_of_use' => 'rules_of_use#new' - post '/rules_of_use' => 'rules_of_use#create' + get '/rules_of_use' => 'users/rules_of_use#new' + post '/rules_of_use' => 'users/rules_of_use#create' get '/piv_cac' => 'users/piv_cac_authentication_setup#new', as: :setup_piv_cac get '/piv_cac_error' => 'users/piv_cac_authentication_setup#error', as: :setup_piv_cac_error From 3a7e5907d6e925c848cc083d9460741dad967e53 Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Fri, 7 May 2021 11:42:47 -0500 Subject: [PATCH 08/32] UpdateUser --- app/forms/rules_of_use_form.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/forms/rules_of_use_form.rb b/app/forms/rules_of_use_form.rb index 6b693411331..609caba0dc6 100644 --- a/app/forms/rules_of_use_form.rb +++ b/app/forms/rules_of_use_form.rb @@ -37,7 +37,6 @@ def submit(params, instructions = nil) def process_successful_submission self.success = true - user.accepted_terms_at = Time.zone.now - user.save! + UpdateUser.new(user: user, attributes: { accepted_terms_at: Time.zone.now }).call end end From 0b6de339ba0f98cf2b06615ceb062bb0194ee885 Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Fri, 7 May 2021 11:44:42 -0500 Subject: [PATCH 09/32] Drop render --- app/controllers/users/rules_of_use_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/users/rules_of_use_controller.rb b/app/controllers/users/rules_of_use_controller.rb index 9af0b19ae04..bc40592b769 100644 --- a/app/controllers/users/rules_of_use_controller.rb +++ b/app/controllers/users/rules_of_use_controller.rb @@ -6,7 +6,6 @@ class RulesOfUseController < ApplicationController def new analytics.track_event(Analytics::RULES_OF_USE_VISIT) @rules_of_use_form = new_rules_of_use_form - render :new, locals: { request_id: nil }, formats: :html end def create From 50f48af59ed2eab65d0f8b726eca48a90856f1fb Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Fri, 7 May 2021 12:07:01 -0500 Subject: [PATCH 10/32] MarketingSite.security_and_privacy_practices_url --- app/views/rules_of_use/new.html.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/rules_of_use/new.html.erb b/app/views/rules_of_use/new.html.erb index ff328c2001a..072ebfc919e 100644 --- a/app/views/rules_of_use/new.html.erb +++ b/app/views/rules_of_use/new.html.erb @@ -16,8 +16,9 @@
    <%= f.check_box :terms_accepted, { class: 'usa-checkbox__input', required: true, aria: { invalid: false } }, true, false %> -
    - <%= f.input :request_id, as: :hidden, input_html: { value: params[:request_id] || request_id } %> <%= f.button :button, t('forms.buttons.continue'), type: :submit, class: 'usa-button--big grid-col-8 mobile-lg:grid-col-6' %> <% end %> From b057bbc2501282cf6ae7a294c219522bf750fc51 Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Mon, 10 May 2021 22:32:22 -0500 Subject: [PATCH 25/32] Simply add [required] to the selector in form-validation.js --- app/javascript/packs/form-validation.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/app/javascript/packs/form-validation.js b/app/javascript/packs/form-validation.js index 618481f9147..0a3fd242d26 100644 --- a/app/javascript/packs/form-validation.js +++ b/app/javascript/packs/form-validation.js @@ -18,9 +18,12 @@ function disableFormSubmit(event) { } /** - * @param {HTMLInputElement} input + * Given an `input` or `invalid` event, updates custom validity of the given input. + * + * @param {Event} event Input or invalid event. */ -function validateInput(input) { +function checkInputValidity(event) { + const input = /** @type {HTMLInputElement} */ (event.target); input.setCustomValidity(''); input.setAttribute('aria-invalid', String(!input.validity.valid)); if ( @@ -49,22 +52,12 @@ function validateInput(input) { } } -/** - * Given an `input` or `invalid` event, updates custom validity of the given input. - * - * @param {Event} event Input or invalid event. - */ -function checkInputValidity(event) { - const input = /** @type {HTMLInputElement} */ (event.target); - validateInput(input); -} - /** * Binds validation to a given input. * * @param {HTMLInputElement} input Input element. */ -function addInputValidationListeners(input) { +function validateInput(input) { input.addEventListener('input', checkInputValidity); input.addEventListener('invalid', checkInputValidity); } From 23b92893ff9e0d3a1a55094e6aa87856d0d0b598 Mon Sep 17 00:00:00 2001 From: Steve Urciuoli Date: Fri, 21 May 2021 13:51:46 -0500 Subject: [PATCH 26/32] rules of use url --- app/views/users/rules_of_use/new.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/rules_of_use/new.html.erb b/app/views/users/rules_of_use/new.html.erb index ae846e3a348..d0375d64393 100644 --- a/app/views/users/rules_of_use/new.html.erb +++ b/app/views/users/rules_of_use/new.html.erb @@ -19,7 +19,7 @@ required: true, aria: { invalid: false } }, true, false %>