Module: RPlatform::Rails::SessionExtensions

Defined in:
lib/rplatform_rails/session_extensions.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:section: Extension Helpers



78
79
80
81
82
83
# File 'lib/rplatform_rails/session_extensions.rb', line 78

def self.included(base) # :nodoc:
  base.class_eval do
    alias_method_chain :initialize,   :rplatform
    alias_method_chain :new_session,  :rplatform
  end
end

Instance Method Details

#force_to_be_new!Object

:section: New Methods



38
39
40
# File 'lib/rplatform_rails/session_extensions.rb', line 38

def force_to_be_new! # :nodoc:
  @force_to_be_new = true
end

#initialize_with_rplatform(request, options = {}) ⇒ Object

:nodoc:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/rplatform_rails/session_extensions.rb', line 56

def initialize_with_rplatform(request, options = {}) # :nodoc:
  
  # only try to use the sig when we don't have a cookie (i.e., in the canvas)
  if session_id_available?(request)
    
    # try a few different ways
    RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Attempting to use fb_sig_session_key as a session key, since we are inside the canvas"
    @fb_sig_session_id = lookup_request_parameter(request, "fb_sig_session_key")
    
    # we only want to change the session_id if we got one from the fb_sig
    if @fb_sig_session_id
      options["session_id"] = Digest::MD5.hexdigest(@fb_sig_session_id)
      RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: using MD5 of fb_sig_session_key [#{options['session_id']}] for the Rails session id"
    end
  end
  
  # now call the default Rails session initialization
  initialize_without_rplatform(request, options)
end

#new_session_with_rplatformObject

:section: Base Overrides



48
49
50
51
52
53
54
# File 'lib/rplatform_rails/session_extensions.rb', line 48

def new_session_with_rplatform # :nodoc:
  if @force_to_be_new
    return true
  else
    return new_session_without_rplatform
  end
end

#using_facebook_session_id?Boolean

:nodoc:

Returns:

  • (Boolean)


42
43
44
# File 'lib/rplatform_rails/session_extensions.rb', line 42

def using_facebook_session_id? # :nodoc:
  return (@fb_sig_session_id != nil)
end