diff --git a/lib/rucaptcha/controller_helpers.rb b/lib/rucaptcha/controller_helpers.rb index 4061f2a..7f6028a 100644 --- a/lib/rucaptcha/controller_helpers.rb +++ b/lib/rucaptcha/controller_helpers.rb @@ -29,12 +29,15 @@ module RuCaptcha # params: # resource - [optional] a ActiveModel object, if given will add validation error message to object. # :keep_session - if true, RuCaptcha will not delete the captcha code session. + # :captcha - if given, the value of it will be used to verify the captcha, + # if do not give or blank, the value of params[:_rucaptcha] will be used to verify the captcha # # exmaples: # # verify_rucaptcha? # verify_rucaptcha?(user, keep_session: true) # verify_rucaptcha?(nil, keep_session: true) + # verify_rucaptcha?(nil, captcha: params[:user][:captcha]) # def verify_rucaptcha?(resource = nil, opts = {}) opts ||= {} @@ -54,7 +57,7 @@ module RuCaptcha end # Make sure parama have captcha - captcha = (params[:_rucaptcha] || '').downcase.strip + captcha = (opts[:captcha] || params[:_rucaptcha] || '').downcase.strip if captcha.blank? return add_rucaptcha_validation_error end diff --git a/lib/rucaptcha/version.rb b/lib/rucaptcha/version.rb index ac6c77f..ff0538d 100644 --- a/lib/rucaptcha/version.rb +++ b/lib/rucaptcha/version.rb @@ -1,3 +1,3 @@ module RuCaptcha - VERSION = '2.3.1' + VERSION = '2.3.2' end diff --git a/lib/rucaptcha/view_helpers.rb b/lib/rucaptcha/view_helpers.rb index 7a5cec2..d913c88 100644 --- a/lib/rucaptcha/view_helpers.rb +++ b/lib/rucaptcha/view_helpers.rb @@ -6,8 +6,8 @@ module RuCaptcha opts[:autocorrect] = 'off' opts[:autocapitalize] = 'off' opts[:pattern] = '[a-zA-Z]*' - opts[:maxlength] = 5 opts[:autocomplete] = 'off' + opts[:maxlength] ||= 5 tag(:input, opts) end