Sha256: 43efad4dfe2ab538b80969b2f885867b4690c74db593c7a4a32e33edac388ff7

Contents?: true

Size: 1018 Bytes

Versions: 2

Compression:

Stored size: 1018 Bytes

Contents

module Netzke
  module ControllerExtensions
    def self.included(base)
      base.send(:before_filter, :set_session_data)
      base.send(:before_filter, :set_controller)
    end

    def set_session_data
      ::Netzke::Core.session = session
      session[:netzke_user_id] = defined?(current_user) ? current_user.try(:id) : nil
      # set netzke_just_logged_in and netzke_just_logged_out states (may be used by Netzke components)
      if session[:_netzke_next_request_is_first_after_login]
        session[:netzke_just_logged_in] = true
        session[:_netzke_next_request_is_first_after_login] = false
      else
        session[:netzke_just_logged_in] = false
      end

      if session[:_netzke_next_request_is_first_after_logout]
        session[:netzke_just_logged_out] = true
        session[:_netzke_next_request_is_first_after_logout] = false
      else
        session[:netzke_just_logged_out] = false
      end
    end

    def set_controller
       ::Netzke::Core.controller = self
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netzke-core-0.6.4 lib/netzke/rails/controller_extensions.rb
netzke-core-0.6.3 lib/netzke/rails/controller_extensions.rb