Commit 5e1be3e43901afa6fa4e71d968c198bb1ca92cf5
1 parent
e7c62647
Exists in
master
and in
28 other branches
ActionItem537: added captcha to signup
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2160 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
16 additions
and
1 deletions
Show diff stats
app/controllers/public/account_controller.rb
1 | 1 | class AccountController < PublicController |
2 | 2 | |
3 | + inverse_captcha :field => 'e_mail' | |
4 | + | |
3 | 5 | # say something nice, you goof! something sweet. |
4 | 6 | def index |
5 | 7 | unless logged_in? |
... | ... | @@ -39,7 +41,7 @@ class AccountController < PublicController |
39 | 41 | @user = User.new(params[:user]) |
40 | 42 | @user.terms_of_use = environment.terms_of_use |
41 | 43 | @terms_of_use = environment.terms_of_use |
42 | - if request.post? && answer_correct | |
44 | + if request.post? && params[self.icaptcha_field].blank? && answer_correct | |
43 | 45 | @user.save! |
44 | 46 | @user.person.environment = environment |
45 | 47 | @user.person.save! | ... | ... |
app/views/account/signup.rhtml
test/functional/account_controller_test.rb
... | ... | @@ -400,6 +400,17 @@ class AccountControllerTest < Test::Unit::TestCase |
400 | 400 | |
401 | 401 | end |
402 | 402 | |
403 | + should 'not be able to signup while inverse captcha field filled' do | |
404 | + assert_no_difference User, :count do | |
405 | + create_user({}, @controller.icaptcha_field => 'bli@bla.email.foo') | |
406 | + end | |
407 | + end | |
408 | + | |
409 | + should 'render inverse captcha field' do | |
410 | + get :signup | |
411 | + assert_tag :tag => 'input', :attributes => { :type => 'text', :name => @controller.icaptcha_field } | |
412 | + end | |
413 | + | |
403 | 414 | protected |
404 | 415 | def create_user(options = {}, extra_options ={}) |
405 | 416 | post :signup, { :user => { :login => 'quire', | ... | ... |