Sha256: adc7378017fe51bb9fd18dc7963dc478e7590ad7e86ec9b19cb4a4d1797d59f6

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)
        warder.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.1 lib/rails_warden/controller_mixin.rb
rails_warden-0.2.1 lib/rails_warden/controller_mixin.rb