Sha256: 87ef42c5c9483f201a4ac2157b7ae4f7846b992ec15ac9f8845d7bcc92fa333c

Contents?: true

Size: 969 Bytes

Versions: 6

Compression:

Stored size: 969 Bytes

Contents

module RailsWarden
  class Manager
    
    def self.new(app, opts = {}, &block)
      # Get the failure application
      opts[:failure_app] = opts[:failure_app].to_s.classify.constantize if opts[:failure_app]
      opts[:default_strategies] = [opts[:defaults]].flatten if opts[:defaults]
      
      # Set the default user
      if user = opts.delete(:default_user)
        RailsWarden.default_user_class = user.to_s.classify.constantize
      end
      
      # Set the unauthenticated action if it's set
      if ua = opts.delete(:unauthenticated_action)
        RailsWarden.unauthenticated_action = ua
      end
      
      # Rails needs the action to be passed in with the params
      Warden::Manager.before_failure do |env, opts|
        if request = env["action_controller.rescue.request"]
          request.params["action"] = RailsWarden.unauthenticated_action
        end
      end
      
      Warden::Manager.new(app, opts, &block)
    end
    
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
hassox-rails_warden-0.2.0 lib/rails_warden/manager.rb
hassox-rails_warden-0.2.1 lib/rails_warden/manager.rb
hassox-rails_warden-0.2.2 lib/rails_warden/manager.rb
rails_warden-0.2.2 lib/rails_warden/manager.rb
rails_warden-0.2.0 lib/rails_warden/manager.rb
rails_warden-0.2.1 lib/rails_warden/manager.rb