Module: Devise::Models::Oauth2FacebookGrantable

Extended by:
ActiveSupport::Concern
Defined in:
lib/devise/oauth2_facebook_grantable/models/oauth2_facebook_grantable.rb

Instance Method Summary collapse

Instance Method Details

#valid_facebook_access_token?(token) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
14
# File 'lib/devise/oauth2_facebook_grantable/models/oauth2_facebook_grantable.rb', line 5

def valid_facebook_access_token?(token)
    fb_user = Devise::Oauth2ProvidableFacebook.facebook_user_for_token(token)
    if(fb_user && fb_user["id"])
      Devise::Oauth2ProvidableFacebook.logger.debug("Oauth2FacebookGrantable => User with facebook identifier \"#{fb_user["id"]}\" was authenticated successfully by Facebook")
      return (fb_user["id"].to_s == self.facebook_identifier.to_s)
    else
      Devise::Oauth2ProvidableFacebook.logger.debug("Oauth2FacebookGrantable => Could not authenticate user against Facebook (#{fb_user})")
      return false
    end
end