Module: Aritcaptcha::AritcaptchaVerify

Defined in:
lib/aritcaptcha/aritcaptcha_verify.rb

Constant Summary collapse

SOLV_KEY =
0
SOLV =
1

Instance Method Summary collapse

Instance Method Details

#clean(image) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/aritcaptcha/aritcaptcha_verify.rb', line 16

def clean image
  unless image == nil
    relative_name = "equacao-#{image}.png"
    full_path     = "#{Rails.root}/public/images/#{relative_name}"
    File.delete(full_path)
   end
end

#verify_aritcaptcha(params) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/aritcaptcha/aritcaptcha_verify.rb', line 7

def verify_aritcaptcha(params)
  if (equation_key = params[:equation_key]) and (equation = params[:equation])
    if session[:equation] and session[:equation][SOLV_KEY] == equation_key.to_i and session[:equation][SOLV] == equation.to_i
      clean session[:image] 
      return true
    end
  end          
end