Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Commit

Permalink
Fixing some session errors (by cassiano)
Browse files Browse the repository at this point in the history
  • Loading branch information
reu committed Sep 20, 2011
1 parent e4393a4 commit 3371d86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/traptcha/controller_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module ControllerHelpers
end

def valid_captcha?
params[:captcha] && session[:captcha] && Traptcha::Captcha.new(params[:captcha]).value == session[:captcha]
params[:captcha] && params[:secure_hash] && Traptcha::Captcha.new(params[:captcha]).value == params[:secure_hash]
end

def validate_captcha
raise Traptcha::InvalidCaptcha unless valid_captcha?
end
Expand Down
6 changes: 5 additions & 1 deletion lib/traptcha/view_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require 'base64'

module Traptcha
module ViewHelpers
def captcha_image_tag
tag :img, :src => "#{captcha_path}?#{rand}", :id => 'traptcha', :alt => 'captcha'
captcha = Traptcha::Captcha.generate

tag(:img, :src => "data:image/png;base64,#{Base64.encode64(captcha.to_png)}", :id => 'traptcha', :alt => 'captcha') + hidden_field_tag(:secure_hash, captcha.value)
end

def captcha_label_tag
Expand Down

0 comments on commit 3371d86

Please sign in to comment.