Skip to content

Commit

Permalink
DM-5904: Don't render reCAPTCHA for VA users (#990)
Browse files Browse the repository at this point in the history
* Don't render reCAPTCHA for VA users

* update nomination form recaptcha minum score to 0.5

---------

Co-authored-by: Camille Villa <[email protected]>
Co-authored-by: PhilipDeFraties <[email protected]>
  • Loading branch information
3 people authored Aug 21, 2024
1 parent e5df1b6 commit 8a83483
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/nominate_practices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def email
handle_nomination
else
begin
recaptcha_result = verify_recaptcha(action: 'email', minimum_score: 0.3)
recaptcha_result = verify_recaptcha(action: 'email', minimum_score: 0.5)

if recaptcha_result
handle_nomination
Expand Down
5 changes: 4 additions & 1 deletion app/views/shared/_email_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
<input type="submit" value="Send message" class="usa-button margin-right-0">
</div>

<%= recaptcha_v3(action: 'email', turbo: 'true', site_key: ENV['RECAPTCHA_SITE_KEY_V3']) if ENV['RECAPTCHA_SITE_KEY_V3'] %>
<% unless current_user.present? %>
<span id="recaptcha-placeholder"></span>
<%= recaptcha_v3(action: 'email', turbo: 'true', site_key: ENV['RECAPTCHA_SITE_KEY_V3']) if ENV['RECAPTCHA_SITE_KEY_V3'] %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
it 'renders form' do
visit '/nominate-an-innovation'
expect(page).to be_accessible.according_to :wcag2a, :section508
expect(page).to have_css('#recaptcha-placeholder', visible: false)
expect(page).to have_content('Nominate an innovation')
expect(page).to have_content('VA staff and collaborators are welcome to nominate active innovations for consideration on the Diffusion Marketplace using the form below.')
end
Expand All @@ -13,6 +14,13 @@
visit '/nominate-a-practice'
expect(page).to have_current_path(nominate_an_innovation_path)
end

it 'does not render reCAPTCHA for VA users' do
@user = User.create!(email: '[email protected]', password: 'Password123', password_confirmation: 'Password123', skip_va_validation: true, confirmed_at: Time.now, accepted_terms: true)
login_as(@user, :scope => :user, :run_callbacks => false)
visit '/nominate-an-innovation'
expect(page).not_to have_selector('#recaptcha-placeholder')
end
end

context 'Email' do
Expand Down

0 comments on commit 8a83483

Please sign in to comment.