Commit 52c8beaa10a246bc36ad60a568811644412f87ff
Exists in
staging
and in
1 other branch
Merge branch 'rename_test_captcha_to_verify_captcha' into staging
Showing
7 changed files
with
15 additions
and
15 deletions
Show diff stats
lib/noosfero/api/helpers.rb
| @@ -435,8 +435,8 @@ require_relative '../../find_by_contents' | @@ -435,8 +435,8 @@ require_relative '../../find_by_contents' | ||
| 435 | # captcha_helpers # | 435 | # captcha_helpers # |
| 436 | ########################################## | 436 | ########################################## |
| 437 | 437 | ||
| 438 | - def test_captcha(remote_ip, params, environment) | ||
| 439 | - captcha_plugin_enabled = @plugins.dispatch(:test_captcha, remote_ip, params, environment).map {|p| p if ! ( p===nil ) } | 438 | + def verify_captcha(remote_ip, params, environment) |
| 439 | + captcha_plugin_enabled = @plugins.dispatch(:verify_captcha, remote_ip, params, environment).map {|p| p if ! ( p===nil ) } | ||
| 440 | return true if captcha_plugin_enabled.size == 0 | 440 | return true if captcha_plugin_enabled.size == 0 |
| 441 | if captcha_plugin_enabled.size > 1 | 441 | if captcha_plugin_enabled.size > 1 |
| 442 | return render_api_error!(_("Error processing Captcha"), 500, nil, "More than one captcha plugin enabled") | 442 | return render_api_error!(_("Error processing Captcha"), 500, nil, "More than one captcha plugin enabled") |
lib/noosfero/api/session.rb
| @@ -12,9 +12,9 @@ module Noosfero | @@ -12,9 +12,9 @@ module Noosfero | ||
| 12 | ################################ | 12 | ################################ |
| 13 | post "/login-captcha" do | 13 | post "/login-captcha" do |
| 14 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) | 14 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) |
| 15 | - # test_captcha will render_api_error! and exit in case of any problem | 15 | + # verify_captcha will render_api_error! and exit in case of any problem |
| 16 | # this return is just to improve the clarity of the execution path | 16 | # this return is just to improve the clarity of the execution path |
| 17 | - return unless test_captcha(remote_ip, params, environment) | 17 | + return unless verify_captcha(remote_ip, params, environment) |
| 18 | ## Creates and caches a captcha session store | 18 | ## Creates and caches a captcha session store |
| 19 | store = Noosfero::API::SessionStore.create("captcha") | 19 | store = Noosfero::API::SessionStore.create("captcha") |
| 20 | ## Initialize the data for the session store | 20 | ## Initialize the data for the session store |
| @@ -70,9 +70,9 @@ module Noosfero | @@ -70,9 +70,9 @@ module Noosfero | ||
| 70 | post "/register" do | 70 | post "/register" do |
| 71 | attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields | 71 | attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields |
| 72 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) | 72 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) |
| 73 | - # test_captcha will render_api_error! and exit in case of any problem | 73 | + # verify_captcha will render_api_error! and exit in case of any problem |
| 74 | # this return is just to improve the clarity of the execution path | 74 | # this return is just to improve the clarity of the execution path |
| 75 | - return unless test_captcha(remote_ip, params, environment) | 75 | + return unless verify_captcha(remote_ip, params, environment) |
| 76 | 76 | ||
| 77 | name = params[:name].present? ? params[:name] : attrs[:email] | 77 | name = params[:name].present? ? params[:name] : attrs[:email] |
| 78 | attrs[:password_confirmation] = attrs[:password] if !attrs.has_key?(:password_confirmation) | 78 | attrs[:password_confirmation] = attrs[:password] if !attrs.has_key?(:password_confirmation) |
| @@ -134,9 +134,9 @@ module Noosfero | @@ -134,9 +134,9 @@ module Noosfero | ||
| 134 | requestors = fetch_requestors(params[:value]) | 134 | requestors = fetch_requestors(params[:value]) |
| 135 | not_found! if requestors.blank? | 135 | not_found! if requestors.blank? |
| 136 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) | 136 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) |
| 137 | - # test_captcha will render_api_error! and exit in case of any problem | 137 | + # verify_captcha will render_api_error! and exit in case of any problem |
| 138 | # this return is just to improve the clarity of the execution path | 138 | # this return is just to improve the clarity of the execution path |
| 139 | - return unless test_captcha(remote_ip, params, environment) | 139 | + return unless verify_captcha(remote_ip, params, environment) |
| 140 | requestors.each do |requestor| | 140 | requestors.each do |requestor| |
| 141 | ChangePassword.create!(:requestor => requestor) | 141 | ChangePassword.create!(:requestor => requestor) |
| 142 | end | 142 | end |
| @@ -152,9 +152,9 @@ module Noosfero | @@ -152,9 +152,9 @@ module Noosfero | ||
| 152 | requestors = fetch_requestors(params[:value]) | 152 | requestors = fetch_requestors(params[:value]) |
| 153 | not_found! if requestors.blank? | 153 | not_found! if requestors.blank? |
| 154 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) | 154 | remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) |
| 155 | - # test_captcha will render_api_error! and exit in case of any problem | 155 | + # verify_captcha will render_api_error! and exit in case of any problem |
| 156 | # this return is just to improve the clarity of the execution path | 156 | # this return is just to improve the clarity of the execution path |
| 157 | - return unless test_captcha(remote_ip, params, environment) | 157 | + return unless verify_captcha(remote_ip, params, environment) |
| 158 | requestors.each do |requestor| | 158 | requestors.each do |requestor| |
| 159 | requestor.user.resend_activation_code | 159 | requestor.user.resend_activation_code |
| 160 | end | 160 | end |
lib/noosfero/plugin.rb
| @@ -679,7 +679,7 @@ class Noosfero::Plugin | @@ -679,7 +679,7 @@ class Noosfero::Plugin | ||
| 679 | end | 679 | end |
| 680 | 680 | ||
| 681 | #By default will return nil that will mean not implented by the plugin | 681 | #By default will return nil that will mean not implented by the plugin |
| 682 | - def test_captcha(*args) | 682 | + def verify_captcha(*args) |
| 683 | nil | 683 | nil |
| 684 | end | 684 | end |
| 685 | 685 |
plugins/recaptcha
plugins/serpro_captcha
test/unit/api/helpers_test.rb
| @@ -254,7 +254,7 @@ class APIHelpersTest < ActiveSupport::TestCase | @@ -254,7 +254,7 @@ class APIHelpersTest < ActiveSupport::TestCase | ||
| 254 | 254 | ||
| 255 | should 'do not test captcha when there is no captcha plugin enabled' do | 255 | should 'do not test captcha when there is no captcha plugin enabled' do |
| 256 | environment = Environment.new | 256 | environment = Environment.new |
| 257 | - assert test_captcha("127.0.0.1", {}, environment) | 257 | + assert verify_captcha("127.0.0.1", {}, environment) |
| 258 | end | 258 | end |
| 259 | 259 | ||
| 260 | ###### END Captcha tests ###### | 260 | ###### END Captcha tests ###### |
test/unit/api/test_helper.rb
| @@ -11,7 +11,7 @@ end | @@ -11,7 +11,7 @@ end | ||
| 11 | module Noosfero | 11 | module Noosfero |
| 12 | module API | 12 | module API |
| 13 | module APIHelpers | 13 | module APIHelpers |
| 14 | - def test_captcha(*args) | 14 | + def verify_captcha(*args) |
| 15 | return true if OutcomeCaptcha.outcome_captcha_test | 15 | return true if OutcomeCaptcha.outcome_captcha_test |
| 16 | render_api_error!("Error testing captcha", 403) | 16 | render_api_error!("Error testing captcha", 403) |
| 17 | end | 17 | end |