diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index 4956d1958..c35db3dd2 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -909,6 +909,7 @@ module JamRuby fb_signup = options[:fb_signup] signup_confirm_url = options[:signup_confirm_url] affiliate_referral_id = options[:affiliate_referral_id] + recaptcha_failed = options[:recaptcha_failed] user = User.new @@ -1031,6 +1032,12 @@ module JamRuby UserMailer.confirm_email(user, signup_confirm_url.nil? ? nil : (signup_confirm_url + "/" + user.signup_token) ).deliver end end + + if recaptcha_failed + user.errors.add "recaptcha", "verification failed" + raise ActiveRecord::Rollback + end + end return user diff --git a/web/Gemfile b/web/Gemfile index 1443a1822..eda57ee0a 100644 --- a/web/Gemfile +++ b/web/Gemfile @@ -50,7 +50,6 @@ gem 'signet', '0.5.0' gem 'twitter' gem 'fb_graph', '2.5.9' gem 'sendgrid', '1.2.0' -gem 'recaptcha', '0.3.4' gem 'filepicker-rails', '0.1.0' gem 'aws-sdk' #, '1.29.1' gem 'aasm', '3.0.16' @@ -66,6 +65,7 @@ gem 'postgres-copy' #end gem 'geokit-rails' gem 'postgres_ext' +gem 'recaptcha', '0.3.6' gem 'resque' gem 'resque-retry' gem 'resque-failed-job-mailer' diff --git a/web/README.md b/web/README.md index 5aca8b9bf..ae45c560b 100644 --- a/web/README.md +++ b/web/README.md @@ -1,4 +1,5 @@ -== TODO: +TODO: +==== Jasmine Javascript Unit Tests ============================= diff --git a/web/app/assets/stylesheets/web/main.css.scss b/web/app/assets/stylesheets/web/main.css.scss index bd5bc2fc5..291f61967 100644 --- a/web/app/assets/stylesheets/web/main.css.scss +++ b/web/app/assets/stylesheets/web/main.css.scss @@ -67,7 +67,7 @@ body.web { .landing-content { background-color:black; width:100%; - min-height: 366px; + min-height: 460px; position:relative; padding-bottom:30px; diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb index c2d92c062..407b9a4c0 100644 --- a/web/app/controllers/users_controller.rb +++ b/web/app/controllers/users_controller.rb @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- require 'builder' +require 'recaptcha/rails' class Slide attr_accessor :img_url, :header, :vid_url @@ -133,14 +134,7 @@ class UsersController < ApplicationController @invited_user = load_invited_user(params) @signup_postback = load_postback(@invited_user, @fb_signup) - @user = User.new - - # check recaptcha; if any errors seen, contribute it to the model - unless verify_recaptcha(:model => @user, :message => "recaptcha") - render 'new', :layout => 'web' - return - end - + instruments = fixup_instruments(params[:jam_ruby_user][:instruments]) birth_date = fixup_birthday(params[:jam_ruby_user]["birth_date(2i)"], params[:jam_ruby_user]["birth_date(3i)"], params[:jam_ruby_user]["birth_date(1i)"]) @@ -148,6 +142,10 @@ class UsersController < ApplicationController terms_of_service = params[:jam_ruby_user][:terms_of_service].nil? || params[:jam_ruby_user][:terms_of_service] == "0"? false : true musician = params[:jam_ruby_user][:musician] + if Rails.application.config.recaptcha_enable + recaptcha_failed = verify_recaptcha(:private_key=>Rails.application.config.recaptcha_private_key, :timeout=>10) + end + @user = UserManager.new.signup(remote_ip: request.remote_ip, first_name: params[:jam_ruby_user][:first_name], last_name: params[:jam_ruby_user][:last_name], @@ -159,11 +157,12 @@ class UsersController < ApplicationController birth_date: birth_date, location: location, musician: musician, + recaptcha_failed: recaptcha_failed, invited_user: @invited_user, fb_signup: @fb_signup, signup_confirm_url: ApplicationHelper.base_uri(request) + "/confirm", affiliate_referral_id: AffiliatePartner.coded_id(self.affiliate_code)) - + # check for errors if @user.errors.any? # render any @user.errors on error @@ -486,5 +485,5 @@ JS else signup_path end - end + end end diff --git a/web/app/views/layouts/web.html.erb b/web/app/views/layouts/web.html.erb index 62c2f1ec6..e3e828bc4 100644 --- a/web/app/views/layouts/web.html.erb +++ b/web/app/views/layouts/web.html.erb @@ -132,6 +132,7 @@ <%= render "shared/ga" %> <%= render "shared/twttr" %> <%= render "shared/facebook_sdk" %> + <%= render "shared/google_nocaptcha" %> diff --git a/web/app/views/shared/_google_nocaptcha.html.slim b/web/app/views/shared/_google_nocaptcha.html.slim new file mode 100644 index 000000000..c0df3c331 --- /dev/null +++ b/web/app/views/shared/_google_nocaptcha.html.slim @@ -0,0 +1 @@ +script src="https://www.google.com/recaptcha/api.js" async defer \ No newline at end of file diff --git a/web/app/views/users/new.html.erb b/web/app/views/users/new.html.erb index 83f79f482..102fafd0b 100644 --- a/web/app/views/users/new.html.erb +++ b/web/app/views/users/new.html.erb @@ -6,7 +6,6 @@ <%= form_for(@user, :url => @signup_postback, :method => :post) do |f| %> -
@@ -38,7 +37,7 @@
<%= f.label :country, "Country:" %>