Sha256: 79c70634f6fa594361dea12ab9527284cf0dbc45b7ff304b8b5f8b329e430781

Contents?: true

Size: 854 Bytes

Versions: 8

Compression:

Stored size: 854 Bytes

Contents

module Fume
  module Authlogic
    def self.try_enable
      if defined? ::Authlogic
        ActionController::Base.send :include, ControllerExtensions::InstanceMethods
        ActionController::Base.send :helper_method, :current_user_session, :current_user
      end
    end
    
    module ControllerExtensions
      module InstanceMethods
        
        protected
        def current_user_session
          return @current_user_session if defined?(@current_user_session)
          @current_user_session = UserSession.find
        end

        def current_user
          return @current_user if defined?(@current_user)
          @current_user = current_user_session && current_user_session.user
        end

        def redirect_to_ok_url_or_default(default)
          redirect_to params[:ok_url] || default
        end
      end
    end
  end
end


Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fume-0.4.1 lib/fume/authlogic.rb
fume-0.4.0 lib/fume/authlogic.rb
fume-0.3.5 lib/fume/authlogic.rb
fume-0.3.4 lib/fume/authlogic.rb
fume-0.3.3 lib/fume/authlogic.rb
fume-0.3.2 lib/fume/authlogic.rb
fume-0.3.1 lib/fume/authlogic.rb
fume-0.3.0 lib/fume/authlogic.rb