Sha256: 89bd9f96e28c16eb197b20df620bc3c308becb64765a929483c2184163bd3e99

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module DeviseSecurity::Patches
  module RegistrationsControllerCaptcha
    extend ActiveSupport::Concern
    included do
      define_method :create do |&block|
        build_resource(sign_up_params)

        if valid_captcha_if_defined?(params[:captcha])
          if resource.save
            block.call(resource) if block
            if resource.active_for_authentication?
              set_flash_message :notice, :signed_up if is_flashing_format?
              sign_up(resource_name, resource)
              respond_with resource, location: after_sign_up_path_for(resource)
            else
              set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
              expire_data_after_sign_in!
              respond_with resource, location: after_inactive_sign_up_path_for(resource)
            end
          else
            clean_up_passwords resource
            respond_with resource
          end

        else
          resource.errors.add :base, t('devise.invalid_captcha')
          clean_up_passwords resource
          respond_with resource
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
devise-security-0.17.0 lib/devise-security/patches/registrations_controller_captcha.rb
devise-security-0.16.0 lib/devise-security/patches/registrations_controller_captcha.rb
devise-security-0.15.0 lib/devise-security/patches/registrations_controller_captcha.rb
devise-security-0.14.3 lib/devise-security/patches/registrations_controller_captcha.rb
devise-security-0.14.2 lib/devise-security/patches/registrations_controller_captcha.rb
devise-security-0.14.1 lib/devise-security/patches/registrations_controller_captcha.rb
devise-security-0.14.0 lib/devise-security/patches/registrations_controller_captcha.rb
devise-security-0.14.0.rc1 lib/devise-security/patches/registrations_controller_captcha.rb
devise-security-0.13.0 lib/devise-security/patches/registrations_controller_captcha.rb