diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 0f63ce8..926b4d5 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -1,5 +1,7 @@ class AccountController < PublicController + inverse_captcha :field => 'e_mail' + # say something nice, you goof! something sweet. def index unless logged_in? @@ -39,7 +41,7 @@ class AccountController < PublicController @user = User.new(params[:user]) @user.terms_of_use = environment.terms_of_use @terms_of_use = environment.terms_of_use - if request.post? && answer_correct + if request.post? && params[self.icaptcha_field].blank? && answer_correct @user.save! @user.person.environment = environment @user.person.save! diff --git a/app/views/account/signup.rhtml b/app/views/account/signup.rhtml index 15ef1c8..32aaef7 100644 --- a/app/views/account/signup.rhtml +++ b/app/views/account/signup.rhtml @@ -24,6 +24,8 @@ :help => help=_('We need to be sure that you wrote correctly your password.') %> <%= help %> +<%= icaptcha_field() %> + <% if @terms_of_use %>

<%= @terms_of_use %> diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index aeb5032..ac6c075 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -400,6 +400,17 @@ class AccountControllerTest < Test::Unit::TestCase end + should 'not be able to signup while inverse captcha field filled' do + assert_no_difference User, :count do + create_user({}, @controller.icaptcha_field => 'bli@bla.email.foo') + end + end + + should 'render inverse captcha field' do + get :signup + assert_tag :tag => 'input', :attributes => { :type => 'text', :name => @controller.icaptcha_field } + end + protected def create_user(options = {}, extra_options ={}) post :signup, { :user => { :login => 'quire', -- libgit2 0.21.2