From f26278e58eb69def7b7e70b81363550c38873769 Mon Sep 17 00:00:00 2001 From: Arvind kushwah Date: Sat, 7 Nov 2020 12:44:44 +0530 Subject: [PATCH] Add recaptcha api js for internal --- app/assets/javascripts/application.js | 2 ++ app/assets/javascripts/recaptcha/api.js | 1 + app/views/devise/registrations/new.html.haml | 4 ++-- app/views/layouts/_head.html.haml | 1 - config/initializers/recaptcha.rb | 8 ++++---- config/settings.yml | 7 +++++++ 6 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 app/assets/javascripts/recaptcha/api.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8f20f8bdf..214e85244 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -49,4 +49,6 @@ //= require browser //= require topbar +// --- Recaptcha +//= require recaptcha/api $(function(){ $(document).foundation(); }); diff --git a/app/assets/javascripts/recaptcha/api.js b/app/assets/javascripts/recaptcha/api.js new file mode 100644 index 000000000..76c7acef3 --- /dev/null +++ b/app/assets/javascripts/recaptcha/api.js @@ -0,0 +1 @@ +/* PLEASE DO NOT COPY AND PASTE THIS CODE. */(function(){var w=window,C='___grecaptcha_cfg',cfg=w[C]=w[C]||{},N='grecaptcha';var gr=w[N]=w[N]||{};gr.ready=gr.ready||function(f){(cfg['fns']=cfg['fns']||[]).push(f);};w['__recaptcha_api']='https://www.google.com/recaptcha/api2/';(cfg['render']=cfg['render']||[]).push('onload');w['__google_recaptcha_client']=true;var d=document,po=d.createElement('script');po.type='text/javascript';po.async=true;po.src='https://www.gstatic.com/recaptcha/releases/1AZgzF1o3OlP73CVr69UmL65/recaptcha__en.js';po.crossOrigin='anonymous';po.integrity='sha384-jSGc1DJfUHBT7BEgzYTQ48gjFDkqthDMj6JxtRjMZ5vRWJTCXgZR/6dFFLoyp6xc';var e=d.querySelector('script[nonce]'),n=e&&(e['nonce']||e.getAttribute('nonce'));if(n){po.setAttribute('nonce',n);}var s=d.getElementsByTagName('script')[0];s.parentNode.insertBefore(po, s);})(); \ No newline at end of file diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 57596f87a..e4b109dc1 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -36,8 +36,8 @@ label: t('simple_form.labels.user.accept_terms_of_use').html_safe .row .medium-12.columns - / = recaptcha_tags - .g-recaptcha{"data-sitekey" => "6LfpkN4ZAAAAAHkHFAbtd1p6uNkK7mISiVfx1YDh"} + = recaptcha_tags + / .g-recaptcha{"data-sitekey" => "#{Settings.recaptcha.site_key}"} / .g-recaptcha{"data-callback" => "recaptchaCallback", "data-sitekey" => "6Lctit4ZAAAAAErhRLHN95FO7WoyOjTrhJd8_0sc"} .row .medium-12.columns.medium-text-left diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 05b53d570..4c4979720 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -19,7 +19,6 @@ %link{ href: "/images/apple-touch-icon.png", rel: "apple-touch-icon" }/ %link{ href: "/images/apple-touch-icon-72x72.png", rel: "apple-touch-icon", sizes: "72x72" }/ %link{ href: "/images/apple-touch-icon-114x114.png", rel: "apple-touch-icon", sizes: "114x114" }/ - %script{:src => "https://www.google.com/recaptcha/api.js"} -# WEBFONTS - if Rails.env.production? diff --git a/config/initializers/recaptcha.rb b/config/initializers/recaptcha.rb index 137fa5b33..2d74035d9 100644 --- a/config/initializers/recaptcha.rb +++ b/config/initializers/recaptcha.rb @@ -1,4 +1,4 @@ -Recaptcha.configure do |config| - config.site_key = '6LfKJt4ZAAAAAKmwBpl9NLj5xTCjnvPBnmmmRI61' - config.secret_key = '6LfKJt4ZAAAAAJDRUvE8j0O7NGNeHjk-jAVFwS9K' -end \ No newline at end of file +# Recaptcha.configure do |config| +# config.site_key = Settings.recaptcha.site_key +# config.secret_key = Settings.recaptcha.secret_key +# end \ No newline at end of file diff --git a/config/settings.yml b/config/settings.yml index cda54f7a8..f7a5677ac 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -241,3 +241,10 @@ devices: # user: device aws_access_key_id: should be overridden via settings.local.yml aws_secret_access_key: should be overridden via settings.local.yml + +# recapcha: +# site_key: 6LfpkN4ZAAAAAHkHFAbtd1p6uNkK7mISiVfx1YDh + +recaptcha: + site_key: 6LfKJt4ZAAAAAKmwBpl9NLj5xTCjnvPBnmmmRI61 + secret_key: 6LfKJt4ZAAAAAJDRUvE8j0O7NGNeHjk-jAVFwS9K \ No newline at end of file