Class: Challah::Facebook::Technique
- Inherits:
-
Object
- Object
- Challah::Facebook::Technique
- Defined in:
- lib/challah/facebook/technique.rb
Instance Method Summary collapse
- #authenticate ⇒ Object
-
#initialize(session) ⇒ Technique
constructor
A new instance of Technique.
- #persist? ⇒ Boolean
Constructor Details
#initialize(session) ⇒ Technique
Returns a new instance of Technique.
4 5 6 7 8 |
# File 'lib/challah/facebook/technique.rb', line 4 def initialize(session) @provider = session.provider? ? session.provider : nil @token = session.token? ? session.token : nil @uid = session.uid? ? session.uid.to_s.strip : nil end |
Instance Method Details
#authenticate ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/challah/facebook/technique.rb', line 10 def authenticate return nil unless @provider == 'facebook' return nil unless @token auth = ::Authorization.where(provider: 'facebook', uid: @uid).first if auth token = Facebook.interface.get_extended_token(@token) test_uid = Facebook.interface.get_facebook_uid_from_access_token(token).to_s.strip # If the uid from the given token matches the provided uid, update the token # and allow access if test_uid and @uid == test_uid auth.update_attribute(:token, token) return auth.user end end nil end |
#persist? ⇒ Boolean
31 32 33 |
# File 'lib/challah/facebook/technique.rb', line 31 def persist? true end |