Sha256: 9ff15b56c76388f3ce6a1ad33db952bd4cfc29c399d0bfc9f04bf54176fcd67c

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

module RailsWarden
  module Mixins    
    module HelperMethods
      # The main accessor for the warden proxy instance
      # :api: public
      def warden
        request.env['warden']
      end
      
      # Proxy to the authenticated? method on warden
      # :api: public
      def authenticated?(*args)
        warden.authenticated?(*args)
      end
      alias_method :logged_in?, :authenticated?
      
      # Access the currently logged in user
      # :api: public
      def user(*args)
        warden.user(*args)
      end
      alias_method :current_user, :user
      
      def user=(user)
        warden.set_user user
      end
      alias_method :current_user=, :user=
    end # Helper Methods
    
    module ControllerOnlyMethods
      # Logout the current user
      # :api: public
      def logout(*args)
        warden._session.inspect  # Without this inspect here.  The session does not clear :|
        warden.logout(*args)
      end
      
      # Proxy to the authenticate method on warden
      # :api: public
      def authenticate(*args)
        warden.authenticate(*args)
      end
      
      # Proxy to the authenticate method on warden
      # :api: public
      def authenticate!(*args)
        warden.authenticate!(*args)
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
hassox-rails_warden-0.2.2 lib/rails_warden/controller_mixin.rb
rails_warden-0.2.2 lib/rails_warden/controller_mixin.rb