Sha256: 93a7aa9d9715fd14d25b97eaee8d31cc10ab07692cc033f3f685d7958af46316

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

module Reactor

  class Engine < Rails::Engine

    initializer "reactor.rsession" do
      # FIXME: extract !
      AbstractController::Base.__send__(:define_method, :rsession) do
        self.session[:rsession] ||= Reactor::Session.instance
      end
      ActionController::Base.__send__(:helper_method, :rsession)

      ActionController::Base.__send__(:define_method, :rsession_auth) do
        if RailsConnector::Configuration.mode == :editor && (jsessionid = cookies['JSESSIONID']).present?
          # Why the gsub? It's a dirty hack! Reason: JSESSIONIDs are unescaped
          # when read through Rails and hence all + are converted into spaces.
          # CM Kernel though stores escaped IDs.
          # From the possible generated characters only the + seems to be
          # problematic.
          # CGI.escape would be the solution, but it's deprecated
          # URI.escape does too much
          jsessionid.gsub!(' ','+')

          Rails.logger.info "Trying to log in at #{Reactor::Configuration.xml_access[:host]}:#{Reactor::Configuration.xml_access[:port]} with JSESSIONID=#{jsessionid}."
          rsession.login(jsessionid)
          Rails.logger.info %|Logged in as "#{rsession.user_name}".| if rsession.user?
        else
          rsession.destroy
        end
      end
      ActionController::Base.__send__(:before_filter, :rsession_auth)
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
infopark_reactor-1.6.1 lib/engine.rb
infopark_reactor-1.5.2 lib/engine.rb
infopark_reactor-1.5.1 lib/engine.rb