diff --git a/Gemfile b/Gemfile index 001eb4c38..aa5c4b130 100644 --- a/Gemfile +++ b/Gemfile @@ -34,8 +34,8 @@ gem 'responders' gem 'foundation-rails' gem 'foundation_rails_helper' gem 'acts_as_votable' -gem 'simple_captcha2', require: 'simple_captcha' gem 'ckeditor', '~> 4.1.5' +gem 'invisible_captcha', '~> 0.8.2' gem 'cancancan' gem 'social-share-button', git: 'https://github.com/huacnlee/social-share-button.git', ref: 'e46a6a3e82b86023bc' gem 'initialjs-rails', '0.2.0.1' diff --git a/Gemfile.lock b/Gemfile.lock index a82f0a412..2dca7d163 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -202,6 +202,8 @@ GEM terminal-table (>= 1.5.1) initialjs-rails (0.2.0.1) railties (>= 3.1, < 5.0) + invisible_captcha (0.8.2) + rails jquery-rails (4.1.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -365,8 +367,6 @@ GEM nokogiri (>= 1.4.0) nori (~> 2.4) wasabi (~> 3.4) - simple_captcha2 (0.4.0) - rails (>= 4.1) simplecov (0.11.2) docile (~> 1.1.0) json (~> 1.8) @@ -469,6 +469,7 @@ DEPENDENCIES groupdate i18n-tasks initialjs-rails (= 0.2.0.1) + invisible_captcha (~> 0.8.2) jquery-rails jquery-ui-rails kaminari @@ -492,7 +493,6 @@ DEPENDENCIES rspec-rails (~> 3.3) sass-rails (~> 5.0, >= 5.0.4) savon - simple_captcha2 social-share-button! spring spring-commands-rspec diff --git a/README.md b/README.md index e6181f38c..0ee254d3a 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Frontend tools used include [SCSS](http://sass-lang.com/) over [Foundation](http ## Configuration for development and test environments -Prerequisites: install git, ImageMagick, Ruby 2.2.3, bundler gem, ghostscript and PostgreSQL (>=9.4). +Prerequisites: install git, Ruby 2.2.3, bundler gem, ghostscript and PostgreSQL (>=9.4). ``` git clone https://github.com/consul/consul.git diff --git a/README_ES.md b/README_ES.md index e0392bc51..9ae368848 100644 --- a/README_ES.md +++ b/README_ES.md @@ -27,7 +27,7 @@ Las herramientas utilizadas para el frontend no están cerradas aún. Los estilo ## Configuración para desarrollo y tests -Prerequisitos: tener instalado git, ImageMagick, Ruby 2.2.3, la gema `bundler`, ghostscript y PostgreSQL (9.4 o superior). +Prerequisitos: tener instalado git, Ruby 2.2.3, la gema `bundler`, ghostscript y PostgreSQL (9.4 o superior). ``` diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 475a0bfbe..d59b33b5e 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -746,26 +746,6 @@ form { line-height: $line-height; vertical-align: middle; } - - .captcha { - border: 0; - padding: $line-height/2 0; - - input { - margin-bottom: 0 !important; - } - } - - .button.margin-top { - margin-top: $line-height; - } -} - -.captcha { - - label { - display: none; - } } // 07. Alerts @@ -775,7 +755,7 @@ form { font-family: $font-sans; font-size: $small-font-size; - &.success { + &.success, &.notice { background-color: $success-bg; border-color: $success-border; color: $success-color; @@ -799,7 +779,7 @@ form { } } - &.alert { + &.alert, &.error { background-color: $alert-bg; border-color: $alert-border; color: $alert-color; diff --git a/app/assets/stylesheets/print.css b/app/assets/stylesheets/print.css index 5297826c8..29096ae13 100644 --- a/app/assets/stylesheets/print.css +++ b/app/assets/stylesheets/print.css @@ -24,8 +24,6 @@ img.left { display: none !important; } .icon-proposals { display: none !important; } -.captcha { display: none !important; } - li.name { display: none !important; } li.kind { display: none !important; } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 640adf299..3e1b78d31 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,6 @@ require "application_responder" class ApplicationController < ActionController::Base - include SimpleCaptcha::ControllerHelpers include HasFilters include HasOrders @@ -115,5 +114,4 @@ class ApplicationController < ActionController::Base store_location_for(:user, request.path) end end - end diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index 332d031a5..de2a2276a 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -38,7 +38,7 @@ module CommentableActions @resource = resource_model.new(strong_params) @resource.author = current_user - if @resource.save_with_captcha + if @resource.save track_event redirect_path = url_for(controller: controller_name, action: :show, id: @resource.id) redirect_to redirect_path, notice: t("flash.actions.create.#{resource_name.underscore}") @@ -55,7 +55,7 @@ module CommentableActions def update resource.assign_attributes(strong_params) - if resource.save_with_captcha + if resource.save redirect_to resource, notice: t("flash.actions.update.#{resource_name.underscore}") else load_categories diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index b747cd903..e077e5e8a 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -11,6 +11,8 @@ class DebatesController < ApplicationController feature_flag :debates + invisible_captcha only: [:create, :update], honeypot: :subtitle + has_orders %w{hot_score confidence_score created_at relevance}, only: :index has_orders %w{most_voted newest oldest}, only: :show @@ -45,7 +47,7 @@ class DebatesController < ApplicationController private def debate_params - params.require(:debate).permit(:title, :description, :tag_list, :terms_of_service, :captcha, :captcha_key) + params.require(:debate).permit(:title, :description, :tag_list, :terms_of_service) end def resource_model diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb index 3f4284a06..7d3925e95 100644 --- a/app/controllers/management/proposals_controller.rb +++ b/app/controllers/management/proposals_controller.rb @@ -33,7 +33,7 @@ class Management::ProposalsController < Management::BaseController end def proposal_params - params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :captcha, :captcha_key) + params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service) end def resource_model diff --git a/app/controllers/management/spending_proposals_controller.rb b/app/controllers/management/spending_proposals_controller.rb index 49378ca63..ca723cccc 100644 --- a/app/controllers/management/spending_proposals_controller.rb +++ b/app/controllers/management/spending_proposals_controller.rb @@ -16,7 +16,7 @@ class Management::SpendingProposalsController < Management::BaseController @spending_proposal = SpendingProposal.new(spending_proposal_params) @spending_proposal.author = managed_user - if @spending_proposal.save_with_captcha + if @spending_proposal.save redirect_to management_spending_proposal_path(@spending_proposal), notice: t('flash.actions.create.notice', resource_name: t("activerecord.models.spending_proposal", count: 1)) else render :new @@ -45,7 +45,7 @@ class Management::SpendingProposalsController < Management::BaseController end def spending_proposal_params - params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :terms_of_service, :captcha, :captcha_key) + params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :terms_of_service) end def only_verified_users diff --git a/app/controllers/organizations/registrations_controller.rb b/app/controllers/organizations/registrations_controller.rb index c0f69da33..503c26bc0 100644 --- a/app/controllers/organizations/registrations_controller.rb +++ b/app/controllers/organizations/registrations_controller.rb @@ -1,5 +1,7 @@ class Organizations::RegistrationsController < Devise::RegistrationsController + invisible_captcha only: [:create], honeypot: :address, scope: :user + def new super do |user| user.build_organization @@ -11,7 +13,7 @@ class Organizations::RegistrationsController < Devise::RegistrationsController def create build_resource(sign_up_params) - if resource.valid_with_captcha? + if resource.valid? super do |user| # Removes unuseful "organization is invalid" error message user.errors.messages.delete(:organization) @@ -29,7 +31,7 @@ class Organizations::RegistrationsController < Devise::RegistrationsController private def sign_up_params - params.require(:user).permit(:email, :password, :phone_number, :password_confirmation, :captcha, :captcha_key, :terms_of_service, organization_attributes: [:name, :responsible_name]) + params.require(:user).permit(:email, :password, :phone_number, :password_confirmation, :terms_of_service, organization_attributes: [:name, :responsible_name]) end end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 8567cda14..0b350f687 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -2,6 +2,7 @@ class ProposalsController < ApplicationController include CommentableActions include FlagActions + before_action :parse_search_terms, only: [:index, :suggest] before_action :parse_advanced_search_terms, only: :index before_action :parse_tag_filter, only: :index @@ -10,6 +11,8 @@ class ProposalsController < ApplicationController before_action :load_geozones, only: [:edit, :map, :summary] before_action :authenticate_user!, except: [:index, :show, :map, :summary] + invisible_captcha only: [:create, :update], honeypot: :subtitle + has_orders %w{hot_score confidence_score created_at relevance}, only: :index has_orders %w{most_voted newest oldest}, only: :show @@ -56,7 +59,7 @@ class ProposalsController < ApplicationController private def proposal_params - params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :captcha, :captcha_key, :geozone_id) + params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id) end def retired_params @@ -93,4 +96,5 @@ class ProposalsController < ApplicationController @resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id)) end end + end diff --git a/app/controllers/spending_proposals_controller.rb b/app/controllers/spending_proposals_controller.rb index 9915b0b50..3f590f414 100644 --- a/app/controllers/spending_proposals_controller.rb +++ b/app/controllers/spending_proposals_controller.rb @@ -8,6 +8,8 @@ class SpendingProposalsController < ApplicationController feature_flag :spending_proposals + invisible_captcha only: [:create, :update], honeypot: :subtitle + respond_to :html, :js def index @@ -27,7 +29,7 @@ class SpendingProposalsController < ApplicationController @spending_proposal = SpendingProposal.new(spending_proposal_params) @spending_proposal.author = current_user - if @spending_proposal.save_with_captcha + if @spending_proposal.save notice = t('flash.actions.create.spending_proposal', activity: "#{t('layouts.header.my_activity_link')}") redirect_to @spending_proposal, notice: notice, flash: { html_safe: true } else @@ -49,7 +51,7 @@ class SpendingProposalsController < ApplicationController private def spending_proposal_params - params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name, :terms_of_service, :captcha, :captcha_key) + params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name, :terms_of_service) end def set_geozone_name diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 9d6530017..2b25a5126 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -1,6 +1,8 @@ class Users::RegistrationsController < Devise::RegistrationsController prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy, :finish_signup, :do_finish_signup] + invisible_captcha only: [:create], honeypot: :family_name, scope: :user + def new super do |user| user.use_redeemable_code = true if params[:use_redeemable_code].present? @@ -9,7 +11,7 @@ class Users::RegistrationsController < Devise::RegistrationsController def create build_resource(sign_up_params) - if resource.valid_with_captcha? + if resource.valid? super else render :new @@ -58,8 +60,7 @@ class Users::RegistrationsController < Devise::RegistrationsController def sign_up_params params[:user].delete(:redeemable_code) if params[:user].present? && params[:user][:redeemable_code].blank? params.require(:user).permit(:username, :email, :password, - :password_confirmation, :captcha, - :captcha_key, :terms_of_service, :locale, + :password_confirmation, :terms_of_service, :locale, :redeemable_code) end diff --git a/app/models/debate.rb b/app/models/debate.rb index cdae527f7..840b9c4b5 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -8,7 +8,6 @@ class Debate < ActiveRecord::Base include Searchable include Filterable - apply_simple_captcha acts_as_votable acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases diff --git a/app/models/proposal.rb b/app/models/proposal.rb index e6071e052..d2b97f1c5 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -7,7 +7,6 @@ class Proposal < ActiveRecord::Base include Searchable include Filterable - apply_simple_captcha acts_as_votable acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases diff --git a/app/models/spending_proposal.rb b/app/models/spending_proposal.rb index 3a13935c4..a2c143336 100644 --- a/app/models/spending_proposal.rb +++ b/app/models/spending_proposal.rb @@ -4,7 +4,6 @@ class SpendingProposal < ActiveRecord::Base include Taggable include Searchable - apply_simple_captcha acts_as_votable belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' diff --git a/app/models/user.rb b/app/models/user.rb index ea889ac57..7da80b6fb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,6 @@ class User < ActiveRecord::Base include Verification - apply_simple_captcha devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :async diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index be5c92306..30152b366 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -1,5 +1,8 @@ <%= form_for(@debate) do |f| %> + + <%= render 'shared/errors', resource: @debate %> +
<%= t("debates.form.tags_instructions") %>
@@ -32,10 +37,6 @@ <% end %>