Created
June 10, 2009 18:21
-
-
Save tammersaleh/127397 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fb_cookie_prefix | |
| Facebooker.api_key+"_" | |
| end | |
| def fb_cookie_names | |
| fb_cookie_names = cookies.keys.select{|k| k.starts_with?(fb_cookie_prefix)} | |
| end | |
| def secure_with_cookies! | |
| parsed = {} | |
| fb_cookie_names.each { |key| parsed[key[fb_cookie_prefix.size,key.size]] = cookies[key] } | |
| #returning gracefully if the cookies aren't set or have expired | |
| return unless parsed['session_key'] && parsed['user'] && parsed['expires'] && parsed['ss'] | |
| return unless Time.at(parsed['expires'].to_s.to_f) > Time.now || (parsed['expires'] == "0") | |
| #if we have the unexpired cookies, we'll throw an exception if the sig doesn't verify | |
| verify_signature(parsed,cookies[Facebooker.api_key]) | |
| @facebook_session = new_facebook_session | |
| @facebook_session.secure_with!(parsed['session_key'],parsed['user'],parsed['expires'],parsed['ss']) | |
| @facebook_session | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment