Module: MathCaptcha::ControllerHelpers

Defined in:
lib/math_captcha/controller.rb

Instance Method Summary collapse

Instance Method Details

#math_captcha_valid?Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/math_captcha/controller.rb', line 3

def math_captcha_valid?
  return true if Rails.env.test?
  if params["captcha-value"]
    session_challenge = session[:captcha]
    crypted_challenge = MathCaptcha::Utils.generate_key(params['captcha-value'])
    result = crypted_challenge === session_challenge
    pr "result #{result}"
    return result
  else
    return false
  end
end