Verify fail if captcha was blank in session or params.

This commit is contained in:
anvyzhang 2015-10-26 22:58:16 +08:00
parent 4ec52d887b
commit c62648c766
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