Commit 3a14efd317f17c3b38fd351eb0b479525e3120ad

Authored by Evandro Junior
1 parent b174e8d4

Captcha for 'I forgot my password' feature

Showing 1 changed file with 6 additions and 3 deletions   Show diff stats
lib/noosfero/api/session.rb
@@ -39,8 +39,8 @@ module Noosfero @@ -39,8 +39,8 @@ module Noosfero
39 unique_attributes! User, [:email, :login] 39 unique_attributes! User, [:email, :login]
40 attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields 40 attrs = attributes_for_keys [:email, :login, :password, :password_confirmation] + environment.signup_person_fields
41 remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR']) 41 remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR'])
42 - # test_captcha will render_api_error! and exit in case of some problem  
43 - # this return is only improve the clarity of the execution path 42 + # test_captcha will render_api_error! and exit in case of any problem
  43 + # this return is just to improve the clarity of the execution path
44 return unless test_captcha(remote_ip, params, environment) 44 return unless test_captcha(remote_ip, params, environment)
45 user = User.new(attrs) 45 user = User.new(attrs)
46 if user.save 46 if user.save
@@ -97,7 +97,10 @@ module Noosfero @@ -97,7 +97,10 @@ module Noosfero
97 post "/forgot_password" do 97 post "/forgot_password" do
98 requestors = fetch_requestors(params[:value]) 98 requestors = fetch_requestors(params[:value])
99 not_found! if requestors.blank? 99 not_found! if requestors.blank?
100 - 100 + remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR'])
  101 + # test_captcha will render_api_error! and exit in case of any problem
  102 + # this return is just to improve the clarity of the execution path
  103 + return unless test_captcha(remote_ip, params, environment)
101 requestors.each do |requestor| 104 requestors.each do |requestor|
102 ChangePassword.create!(:requestor => requestor) 105 ChangePassword.create!(:requestor => requestor)
103 end 106 end