Skip to content

Commit

Permalink
Add options{} parameter to verify_recaptcha so we can pass privatekey…
Browse files Browse the repository at this point in the history
… as a parameter, instead of using ENV
  • Loading branch information
gaizka committed Nov 11, 2008
1 parent 3e1bed8 commit 6904f0b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/recaptcha.rb
Expand Up @@ -46,12 +46,13 @@ def recaptcha_tags(options = {})

module Controller
# Your private API key must be specified in the environment variable +RECAPTCHA_PRIVATE_KEY+
def verify_recaptcha(model = nil)
def verify_recaptcha(model = nil, options = {})
return true if SKIP_VERIFY_ENV.include? ENV['RAILS_ENV']
raise ReCaptchaError, "No private key specified." unless ENV['RECAPTCHA_PRIVATE_KEY']
private_key = options[:private_key] ||= ENV['RECAPTCHA_PRIVATE_KEY']
raise ReCaptchaError, "No private key specified." unless private_key
begin
recaptcha = Net::HTTP.post_form URI.parse("http://#{RECAPTCHA_VERIFY_SERVER}/verify"), {
:privatekey => ENV['RECAPTCHA_PRIVATE_KEY'],
:privatekey => private_key,
:remoteip => request.remote_ip,
:challenge => params[:recaptcha_challenge_field],
:response => params[:recaptcha_response_field]
Expand Down

0 comments on commit 6904f0b

Please sign in to comment.