Sha256: e2f62d3daa980ed27e6bf459803bdaaf6282e9aeb43e5caf21be3cf82ac521ac

Contents?: true

Size: 987 Bytes

Versions: 4

Compression:

Stored size: 987 Bytes

Contents

# encoding: utf-8
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

4 entries across 4 versions & 2 rubygems

Version Path
hassox-rails_warden-0.2.3 lib/rails_warden/manager.rb
hassox-rails_warden-0.2.4 lib/rails_warden/manager.rb
rails_warden-0.2.4 lib/rails_warden/manager.rb
rails_warden-0.2.3 lib/rails_warden/manager.rb