module RackWarden::WardenConfig

Public Class Methods

included(base) click to toggle source
# File lib/rack_warden/warden.rb, line 3
def self.included(base)
        App.logger.warn "RW loading Warden config into #{base}"

        base.instance_eval do                        
        
    use Warden::Manager do |config|
      # Tell Warden how to save our User info into a session.
      # Sessions can only take strings, not Ruby code, we'll store
      # the User's `id`
      config.serialize_into_session{|user| user.id }
      # Now tell Warden how to take what we've stored in the session
      # and get a User from that information.
      config.serialize_from_session{|id| User.get(id) }

      config.scope_defaults :default,
        # "strategies" is an array of named methods with which to
        # attempt authentication. We have to define this later.
        :strategies => [:remember_me, :password],
        # The action is a route to send the user to when
        # warden.authenticate! returns a false answer. We'll show
        # this route below.
        :action => 'auth/unauthenticated'
      # When a user tries to log in and cannot, this specifies the
      # app to send the user to.
      config.failure_app = self
    end

        end # self.included
end