From 630d882e6d3505b1cd9ac7031e34bde9f05441ce Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Tue, 5 Mar 2024 12:27:06 -0700 Subject: [PATCH 1/3] Add terms & conditions checkbox to invitation form This adds the terms and conditions checkbox to the devise invitation form. In addition, `accept_terms` has been added to devise_parameter_sanitizer.permit(). This change is required in order for `accept_terms` to be updated within the update method of Devise::InvitationsController. --- app/controllers/application_controller.rb | 2 +- app/views/devise/invitations/edit.html.erb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7f27d0c357..578ee3da95 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -172,7 +172,7 @@ def from_external_domain? end def configure_permitted_parameters - devise_parameter_sanitizer.permit(:accept_invitation, keys: %i[firstname surname org_id]) + devise_parameter_sanitizer.permit(:accept_invitation, keys: %i[firstname surname org_id accept_terms]) end def render_not_found(exception) diff --git a/app/views/devise/invitations/edit.html.erb b/app/views/devise/invitations/edit.html.erb index 586af8dff6..315e98c145 100644 --- a/app/views/devise/invitations/edit.html.erb +++ b/app/views/devise/invitations/edit.html.erb @@ -37,6 +37,15 @@ required: true } %> +
+
+ <%= f.label(:accept_terms) do %> + <%= f.check_box(:accept_terms, "aria-required": true) %> + <%= _('I accept the') %> + <%= link_to _('terms and conditions'), terms_of_use_path %> + <% end %> +
+
<%= f.button(_('Create account'), class: "btn btn-default", type: "submit") %> <% end %> From 1cbf600927f1a38a6729f113e754b64371719d05 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Tue, 5 Mar 2024 12:41:27 -0700 Subject: [PATCH 2/3] Only submit invitation form if terms are accepted This change results in the user being unable to submit the invitation form unless the accept terms checkbox is actually checked. The checkbox handling here is a bit different from the checkbox handling within the create account section of the homepage (see the create method within RegistrationsController). We could do the same here, but it would require a bit more work. Specifically, we'd have to override the Devise::InvitationsController update method within InvitationsController. Also, a bit of extra handling would be required within the DeviseController require_no_authentication method that we are already overriding within InvitationsController. --- app/views/devise/invitations/edit.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/devise/invitations/edit.html.erb b/app/views/devise/invitations/edit.html.erb index 315e98c145..024d35b9b1 100644 --- a/app/views/devise/invitations/edit.html.erb +++ b/app/views/devise/invitations/edit.html.erb @@ -40,7 +40,7 @@
<%= f.label(:accept_terms) do %> - <%= f.check_box(:accept_terms, "aria-required": true) %> + <%= f.check_box(:accept_terms, "aria-required": true, required: true) %> <%= _('I accept the') %> <%= link_to _('terms and conditions'), terms_of_use_path %> <% end %> From de1e2387a712392bf954c9af841e4ecc43bf345e Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Tue, 5 Mar 2024 12:52:20 -0700 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8235a8f039..2cb5ea04a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Bump mysql2 from 0.5.5 to 0.5.6 [#645](https://github.com/portagenetwork/roadmap/pull/645) +- Added "Accept terms and conditions" checkbox to invitation form [#684](https://github.com/portagenetwork/roadmap/pull/684) + ### Fixed - Updated Webmock's allowed request list to enable fetching of chromedriver [#670](https://github.com/portagenetwork/roadmap/pull/670)