diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-03-12 13:05:19 +0000 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-03-12 13:05:19 +0000 |
commit | 37bff4c0154b57b35a3194a9b31a9422496b955b (patch) | |
tree | 61592a6bb9d1d9fea378a6e4efa8fdf7d5525b8a /vendor/gems/recaptcha-0.3.1/lib/recaptcha/verify.rb | |
parent | 8b49dc894066e452232cabd09333895487f86986 (diff) | |
parent | 8acea24f98268fbb9b73b66b9e98a1788a3b30ac (diff) |
Merge branch 'merged-bundler' into develop
Diffstat (limited to 'vendor/gems/recaptcha-0.3.1/lib/recaptcha/verify.rb')
-rw-r--r-- | vendor/gems/recaptcha-0.3.1/lib/recaptcha/verify.rb | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/vendor/gems/recaptcha-0.3.1/lib/recaptcha/verify.rb b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/verify.rb deleted file mode 100644 index 733ce31be..000000000 --- a/vendor/gems/recaptcha-0.3.1/lib/recaptcha/verify.rb +++ /dev/null @@ -1,51 +0,0 @@ -module Recaptcha - module Verify - # Your private API can be specified in the +options+ hash or preferably - # using the Configuration. - def verify_recaptcha(options = {}) - if !options.is_a? Hash - options = {:model => options} - end - - env = options[:env] || ENV['RAILS_ENV'] - return true if Recaptcha.configuration.skip_verify_env.include? env - model = options[:model] - attribute = options[:attribute] || :base - private_key = options[:private_key] || Recaptcha.configuration.private_key - raise RecaptchaError, "No private key specified." unless private_key - - begin - recaptcha = nil - Timeout::timeout(options[:timeout] || 3) do - recaptcha = Net::HTTP.post_form URI.parse(Recaptcha.configuration.verify_url), { - "privatekey" => private_key, - "remoteip" => request.remote_ip, - "challenge" => params[:recaptcha_challenge_field], - "response" => params[:recaptcha_response_field] - } - end - answer, error = recaptcha.body.split.map { |s| s.chomp } - unless answer == 'true' - flash[:recaptcha_error] = error - if model - model.valid? - model.errors.add attribute, options[:message] || "Word verification response is incorrect, please try again." - end - return false - else - flash[:recaptcha_error] = nil - return true - end - rescue Timeout::Error - flash[:recaptcha_error] = "recaptcha-not-reachable" - if model - model.valid? - model.errors.add attribute, options[:message] || "Oops, we failed to validate your word verification response. Please try again." - end - return false - rescue Exception => e - raise RecaptchaError, e.message, e.backtrace - end - end # verify_recaptcha - end # Verify -end # Recaptcha |