Module: CustomCaptcha::ActionControllerExtension::InstanceMethods
- Defined in:
- lib/custom_captcha/action_controller_extension.rb
Instance Method Summary collapse
- #choice_image_file_path_and_write_session_cache ⇒ Object
- #custom_captcha_valid?(captcha_value = nil) ⇒ Boolean
- #read_captcha_digested ⇒ Object
- #read_image_file_path(key) ⇒ Object
Instance Method Details
#choice_image_file_path_and_write_session_cache ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/custom_captcha/action_controller_extension.rb', line 24 def choice_image_file_path_and_write_session_cache image_file_path, captcha_digested, key = CustomCaptcha::Utils.choice_image_file_path_and_generate_captcha_digested_key session[:captcha_digested] = captcha_digested Rails.cache.write(key, [image_file_path, captcha_digested]) key end |
#custom_captcha_valid?(captcha_value = nil) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/custom_captcha/action_controller_extension.rb', line 12 def custom_captcha_valid?(captcha_value=nil) if CustomCaptcha::Configuration.disable? or Rails.env.test? return true end captcha_value ||= params[CustomCaptcha::DEFAULTVALUE[:field_name]] if captcha_value CustomCaptcha::Utils.captcha_value_valid?(captcha_value, read_captcha_digested()) else return false end end |
#read_captcha_digested ⇒ Object
32 33 34 |
# File 'lib/custom_captcha/action_controller_extension.rb', line 32 def read_captcha_digested session[:captcha_digested] end |
#read_image_file_path(key) ⇒ Object
36 37 38 |
# File 'lib/custom_captcha/action_controller_extension.rb', line 36 def read_image_file_path(key) Rails.cache.read(key)[0] rescue nil end |