Merge pull request #3 from anvyzhang/rt_master

Verify fail if captcha was blank in session or params.
This commit is contained in:
Jason Lee 2015-10-26 23:29:17 +08:00
commit 437410bd43
1 changed files with 2 additions and 2 deletions

View File

@ -18,8 +18,8 @@ module RuCaptcha
end
def verify_rucaptcha?(resource = nil)
params[:_rucaptcha] ||= ''
right = params[:_rucaptcha].downcase.strip == session[:_rucaptcha]
right = params[:_rucaptcha].present? and session[:_rucaptcha].present? and
params[:_rucaptcha].downcase.strip == session[:_rucaptcha]
if resource && resource.respond_to?(:errors)
resource.errors.add(:base, t('rucaptcha.invalid')) unless right
end