0
0
Fork 0

Fix CAPTCHA page not following design pattern of sign-up flow (#25395)

This commit is contained in:
Eugen Rochko 2023-06-13 22:30:40 +02:00 committed by GitHub
parent 3b5e302f7f
commit 39110d1d0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 6 deletions

View file

@ -2,6 +2,7 @@
module CaptchaConcern
extend ActiveSupport::Concern
include Hcaptcha::Adapters::ViewMethods
included do
@ -35,18 +36,22 @@ module CaptchaConcern
flash.delete(:hcaptcha_error)
yield message
end
false
end
end
def extend_csp_for_captcha!
policy = request.content_security_policy
return unless captcha_required? && policy.present?
%w(script_src frame_src style_src connect_src).each do |directive|
values = policy.send(directive)
values << 'https://hcaptcha.com' unless values.include?('https://hcaptcha.com') || values.include?('https:')
values << 'https://*.hcaptcha.com' unless values.include?('https://*.hcaptcha.com') || values.include?('https:')
policy.send(directive, *values)
end
end