diff --git a/lib/devise_security_extension/patches/controller_captcha.rb b/lib/devise_security_extension/patches/controller_captcha.rb index 92187074..528594f3 100644 --- a/lib/devise_security_extension/patches/controller_captcha.rb +++ b/lib/devise_security_extension/patches/controller_captcha.rb @@ -3,13 +3,17 @@ module ControllerCaptcha extend ActiveSupport::Concern included do - prepend_before_action :check_captcha, only: [:create] + append_before_action :check_captcha, only: [:create] end private def check_captcha - return if ((defined? verify_recaptcha) && (verify_recaptcha)) || ((defined? valid_captcha?) && (valid_captcha? params[:captcha])) + build_resource(sign_up_params) + if ((defined? verify_recaptcha) && (verify_recaptcha)) || ((defined? valid_captcha?) && (valid_captcha? params[:captcha])) + resource.errors.add :base, t('devise.invalid_captcha') + return resource + end flash[:alert] = t('devise.invalid_captcha') if is_navigational_format? respond_with({}, location: url_for(action: :new)) end