rfacebook 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/facepricot.rb +8 -0
- data/lib/rfacebook_on_rails/controller_extensions.rb +43 -40
- metadata +2 -2
data/lib/facepricot.rb
CHANGED
@@ -107,6 +107,10 @@ module RFacebook
|
|
107
107
|
def to_s
|
108
108
|
return @doc.containers[0].inner_html
|
109
109
|
end
|
110
|
+
|
111
|
+
def get(key)
|
112
|
+
return make_facepricot_chain(key.to_s, @doc.containers[0])
|
113
|
+
end
|
110
114
|
|
111
115
|
end
|
112
116
|
|
@@ -123,6 +127,10 @@ module RFacebook
|
|
123
127
|
return make_facepricot_chain(methodSymbol.to_s, @doc)
|
124
128
|
end
|
125
129
|
|
130
|
+
def get(key)
|
131
|
+
return make_facepricot_chain(key.to_s, @doc)
|
132
|
+
end
|
133
|
+
|
126
134
|
end
|
127
135
|
|
128
136
|
|
@@ -107,20 +107,31 @@ module RFacebook
|
|
107
107
|
|
108
108
|
# if we are in the canvas, iframe, or mock ajax, we should be able to activate the session here
|
109
109
|
if (!rfacebook_session_holder.is_valid? and (in_facebook_canvas? or in_facebook_frame? or in_mock_ajax?))
|
110
|
-
|
110
|
+
|
111
111
|
# then try to activate it somehow (or retrieve from previous state)
|
112
112
|
# these might be nil
|
113
113
|
facebookUid = fbparams["user"]
|
114
114
|
facebookSessionKey = fbparams["session_key"]
|
115
115
|
expirationTime = fbparams["expires"]
|
116
|
-
|
116
|
+
|
117
117
|
if (facebookUid and facebookSessionKey and expirationTime)
|
118
118
|
# we have the user id and key from the fb_sig_ params, activate the session
|
119
119
|
rfacebook_session_holder.activate_with_previous_session(facebookSessionKey, facebookUid, expirationTime)
|
120
|
-
RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Activated session from inside the canvas"
|
120
|
+
RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Activated session from inside the canvas (user=#{facebookUid}, session_key=#{facebookSessionKey}, expires=#{expirationTime})"
|
121
121
|
else
|
122
|
-
RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK WARNING: Tried to
|
122
|
+
RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK WARNING: Tried to get a valid Facebook session from POST params, but failed"
|
123
123
|
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
# if we still don't have a session, check the Rails session
|
128
|
+
# (used for external and iframe apps when fb_sig POST params weren't present)
|
129
|
+
if (!rfacebook_session_holder.is_valid? and session[:rfacebook_session] and session[:rfacebook_session].is_valid?)
|
130
|
+
|
131
|
+
# grab saved Facebook session from Rails session
|
132
|
+
RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: grabbing Facebook session from Rails session"
|
133
|
+
@rfacebook_session_holder = session[:rfacebook_session]
|
134
|
+
@rfacebook_session_holder.logger = RAILS_DEFAULT_LOGGER
|
124
135
|
|
125
136
|
end
|
126
137
|
|
@@ -154,7 +165,8 @@ module RFacebook
|
|
154
165
|
end
|
155
166
|
|
156
167
|
def in_mock_ajax?
|
157
|
-
|
168
|
+
is_mockajax = params["fb_sig_is_mockajax"]
|
169
|
+
return (is_mockajax == "1" || is_mockajax == true || params["fb_mockajax_url"] != nil)
|
158
170
|
end
|
159
171
|
|
160
172
|
def in_external_app?
|
@@ -169,61 +181,52 @@ module RFacebook
|
|
169
181
|
end
|
170
182
|
|
171
183
|
def facebook_platform_signature_verified?
|
172
|
-
return (fbparams and
|
184
|
+
return (fbparams and fbparams.size > 0)
|
173
185
|
end
|
174
186
|
|
175
187
|
# TODO: define something along the lines of is_logged_in_to_facebook? that returns fbsession.is_ready? perhaps
|
176
188
|
|
177
189
|
################################################################################################
|
178
190
|
################################################################################################
|
179
|
-
# :section:
|
191
|
+
# :section: before_filters
|
180
192
|
################################################################################################
|
181
193
|
|
182
194
|
def handle_facebook_login
|
183
195
|
|
184
|
-
|
185
|
-
|
186
|
-
|
196
|
+
# we only do this when we don't have the fb_sig to give us a session
|
197
|
+
# in these cases, we always check to see if we got an auth_token
|
198
|
+
# from redirecting to login to facebook
|
199
|
+
if (!facebook_platform_signature_verified? and params["auth_token"])
|
200
|
+
|
201
|
+
# activate with the auth token
|
202
|
+
RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: attempting to create a new Facebook session from auth_token"
|
203
|
+
staleToken = false
|
204
|
+
begin
|
187
205
|
|
188
|
-
#
|
189
|
-
|
190
|
-
staleToken = false
|
191
|
-
begin
|
192
|
-
|
193
|
-
# try to use the auth_token
|
194
|
-
rfacebook_session_holder.activate_with_token(params["auth_token"])
|
195
|
-
|
196
|
-
rescue StandardError => e
|
197
|
-
RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Tried to use a stale auth_token"
|
198
|
-
staleToken = true
|
199
|
-
end
|
200
|
-
|
201
|
-
# template method call upon success
|
202
|
-
if (rfacebook_session_holder.is_valid? and !staleToken)
|
203
|
-
RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Login was successful, calling finish_facebook_login"
|
204
|
-
if in_external_app?
|
205
|
-
finish_facebook_login
|
206
|
-
end
|
207
|
-
end
|
206
|
+
# try to use the auth_token
|
207
|
+
rfacebook_session_holder.activate_with_token(params["auth_token"])
|
208
208
|
|
209
|
-
|
209
|
+
rescue StandardError => e
|
210
|
+
RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Tried to use a stale auth_token"
|
211
|
+
staleToken = true
|
212
|
+
end
|
210
213
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
214
|
+
# template method call upon success
|
215
|
+
if (rfacebook_session_holder.is_valid? and !staleToken)
|
216
|
+
RAILS_DEFAULT_LOGGER.debug "** RFACEBOOK INFO: Login was successful, calling finish_facebook_login"
|
217
|
+
if in_external_app?
|
218
|
+
finish_facebook_login
|
219
|
+
end
|
216
220
|
end
|
217
|
-
|
221
|
+
|
218
222
|
# warning logs
|
219
223
|
if !rfacebook_session_holder.is_valid?
|
220
|
-
RAILS_DEFAULT_LOGGER.info "** RFACEBOOK WARNING: Facebook session could not be activated
|
224
|
+
RAILS_DEFAULT_LOGGER.info "** RFACEBOOK WARNING: Facebook session could not be activated with auth_token"
|
221
225
|
end
|
222
|
-
|
226
|
+
|
223
227
|
end
|
224
228
|
|
225
229
|
return true
|
226
|
-
|
227
230
|
end
|
228
231
|
|
229
232
|
def require_facebook_login
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rfacebook
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.9.
|
7
|
-
date: 2007-09-
|
6
|
+
version: 0.9.6
|
7
|
+
date: 2007-09-10 00:00:00 -04:00
|
8
8
|
summary: A Ruby interface to the Facebook API v1.0+. Works with RFacebook on Rails plugin (see http://rfacebook.rubyforge.org).
|
9
9
|
require_paths:
|
10
10
|
- lib
|