Sha256: c65e26c61a67f688dd528b88a103a87362720e0136250e0e50af56b757411ed2

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

module DeviseSecurity::Patches
  module SessionsControllerCaptcha
    extend ActiveSupport::Concern
    included do
      define_method :create do |&block|
        if valid_captcha_if_defined?(params[:captcha])
          self.resource = warden.authenticate!(auth_options)
          set_flash_message(:notice, :signed_in) if is_flashing_format?
          sign_in(resource_name, resource)
          block.call(resource) if block
          respond_with resource, :location => after_sign_in_path_for(resource)
        else
          flash[:alert] = t('devise.invalid_captcha') if is_flashing_format?
          respond_with({}, :location => new_session_path(resource_name))
        end
      end

      # for bad protected use in controller
      define_method :auth_options do
        { :scope => resource_name, :recall => "#{controller_path}#new" }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise-security-0.11.1 lib/devise-security/patches/sessions_controller_captcha.rb