Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Resource was null if recaptcha was not completed or invalid this mad… #197

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/devise_security_extension/patches/controller_captcha.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down