Sha256: 8cf3fc285df3cf7b1d7abfe90c90bbf7601ba62c262979667a3e2218fc1bd69d

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module RailsWarden
  module ControllerMixin
    
    def self.included(base)
      base.send(:include, InstanceMethods)
    end
    
    module InstanceMethods
      # The main accessor for the warden proxy instance
      # :api: public
      def warden
        request.env['warden']
      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
      
      # 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
      
      # Logout the current user
      # :api: public
      def logout(*args)
        warden.logout(*args)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_warden-0.1.1 lib/rails_warden/controller_mixin.rb