From 194592303b76bbf0da4c5f8279240fc954387b7c Mon Sep 17 00:00:00 2001 From: Evandro Junior Date: Thu, 11 Feb 2016 13:54:29 -0300 Subject: [PATCH] api: rename test_captcha to verify_captcha --- lib/noosfero/api/helpers.rb | 4 ++-- lib/noosfero/api/session.rb | 16 ++++++++-------- lib/noosfero/plugin.rb | 2 +- plugins/recaptcha | 2 +- plugins/serpro_captcha | 2 +- test/unit/api/helpers_test.rb | 2 +- test/unit/api/test_helper.rb | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/noosfero/api/helpers.rb b/lib/noosfero/api/helpers.rb index cc2511c..9a54085 100644 --- a/lib/noosfero/api/helpers.rb +++ b/lib/noosfero/api/helpers.rb @@ -433,8 +433,8 @@ require_relative '../../find_by_contents' # captcha_helpers # ########################################## - def test_captcha(remote_ip, params, environment) - captcha_plugin_enabled = @plugins.dispatch(:test_captcha, remote_ip, params, environment).map {|p| p if ! ( p===nil ) } + def verify_captcha(remote_ip, params, environment) + captcha_plugin_enabled = @plugins.dispatch(:verify_captcha, remote_ip, params, environment).map {|p| p if ! ( p===nil ) } return true if captcha_plugin_enabled.size == 0 if captcha_plugin_enabled.size > 1 return render_api_error!(_("Error processing Captcha"), 500, nil, "More than one captcha plugin enabled") diff --git a/lib/noosfero/api/session.rb b/lib/noosfero/api/session.rb index 3178fa6..69fe6b9 100644 --- a/lib/noosfero/api/session.rb +++ b/lib/noosfero/api/session.rb @@ -12,9 +12,9 @@ module Noosfero ################################ post "/login-captcha" do remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) - # test_captcha will render_api_error! and exit in case of any problem + # verify_captcha will render_api_error! and exit in case of any problem # this return is just to improve the clarity of the execution path - return unless test_captcha(remote_ip, params, environment) + return unless verify_captcha(remote_ip, params, environment) ## Creates and caches a captcha session store store = Noosfero::API::SessionStore.create("captcha") ## Initialize the data for the session store @@ -70,9 +70,9 @@ module Noosfero post "/register" do attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) - # test_captcha will render_api_error! and exit in case of any problem + # verify_captcha will render_api_error! and exit in case of any problem # this return is just to improve the clarity of the execution path - return unless test_captcha(remote_ip, params, environment) + return unless verify_captcha(remote_ip, params, environment) name = params[:name].present? ? params[:name] : attrs[:email] attrs[:password_confirmation] = attrs[:password] if !attrs.has_key?(:password_confirmation) @@ -134,9 +134,9 @@ module Noosfero requestors = fetch_requestors(params[:value]) not_found! if requestors.blank? remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) - # test_captcha will render_api_error! and exit in case of any problem + # verify_captcha will render_api_error! and exit in case of any problem # this return is just to improve the clarity of the execution path - return unless test_captcha(remote_ip, params, environment) + return unless verify_captcha(remote_ip, params, environment) requestors.each do |requestor| ChangePassword.create!(:requestor => requestor) end @@ -152,9 +152,9 @@ module Noosfero requestors = fetch_requestors(params[:value]) not_found! if requestors.blank? remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) - # test_captcha will render_api_error! and exit in case of any problem + # verify_captcha will render_api_error! and exit in case of any problem # this return is just to improve the clarity of the execution path - return unless test_captcha(remote_ip, params, environment) + return unless verify_captcha(remote_ip, params, environment) requestors.each do |requestor| requestor.user.resend_activation_code end diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index 3114ad5..d464f31 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -679,7 +679,7 @@ class Noosfero::Plugin end #By default will return nil that will mean not implented by the plugin - def test_captcha(*args) + def verify_captcha(*args) nil end diff --git a/plugins/recaptcha b/plugins/recaptcha index 6767abe..e6dcbaf 160000 --- a/plugins/recaptcha +++ b/plugins/recaptcha @@ -1 +1 @@ -Subproject commit 6767abef88d2b78c05b8c0edb67ca28e72348f6f +Subproject commit e6dcbafefb776a5e950e0499df46997478626223 diff --git a/plugins/serpro_captcha b/plugins/serpro_captcha index c6a155b..195958f 160000 --- a/plugins/serpro_captcha +++ b/plugins/serpro_captcha @@ -1 +1 @@ -Subproject commit c6a155b608056d1cba387904e4ca34a5145a073f +Subproject commit 195958f5b26e1e117edff66122b0a388563baa99 diff --git a/test/unit/api/helpers_test.rb b/test/unit/api/helpers_test.rb index 08747f9..0dd56c0 100644 --- a/test/unit/api/helpers_test.rb +++ b/test/unit/api/helpers_test.rb @@ -247,7 +247,7 @@ class APIHelpersTest < ActiveSupport::TestCase should 'do not test captcha when there is no captcha plugin enabled' do environment = Environment.new - assert test_captcha("127.0.0.1", {}, environment) + assert verify_captcha("127.0.0.1", {}, environment) end ###### END Captcha tests ###### diff --git a/test/unit/api/test_helper.rb b/test/unit/api/test_helper.rb index 40d2a47..4356df0 100644 --- a/test/unit/api/test_helper.rb +++ b/test/unit/api/test_helper.rb @@ -11,7 +11,7 @@ end module Noosfero module API module APIHelpers - def test_captcha(*args) + def verify_captcha(*args) return true if OutcomeCaptcha.outcome_captcha_test render_api_error!("Error testing captcha", 403) end -- libgit2 0.21.2