Sha256: 962db880f8b48241f259d30e87f8e2b9102c85629be67af8caf7112b124c9c82

Contents?: true

Size: 1.24 KB

Versions: 33

Compression:

Stored size: 1.24 KB

Contents

require 'action_controller'

# :nodoc: add authenticates_using_facebook
class ActionController::Base  
  # Authenticates users via Facebook OAuth2, using fbgraph_rails.
  #
  # The User model class must implement for_facebook_token. The controller
  # should obtain the Facebook token, using probes_facebook_access_token or
  # requires_facebook_access_token.
  def self.authenticates_using_facebook(options = {})
    include Authpwn::FacebookControllerInstanceMethods
    before_filter :authenticate_using_facebook_access_token, options
  end
end  # module Authpwn::FacebookExtensions::ControllerClassMethods

# :nodoc: namespace
module Authpwn

# Included in controllers that call authenticates_using_facebook.
module FacebookControllerInstanceMethods
  def authenticate_using_facebook_access_token
    return true if current_user
    if access_token = current_facebook_access_token
      self.current_user = User.for_facebook_token access_token
      # NOTE: nixing the token from the session so the user won't be logged on
      #       immediately after logging off
      self.current_facebook_access_token = nil
    end
  end
  private :authenticate_using_facebook_access_token
end  # module Authpwn::FacebookControllerInstanceMethods

end  # namespace Authpwn

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
authpwn_rails-0.16.2 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.16.1 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.16.0 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.15.3 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.15.2 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.15.1 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.15.0 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.14.3 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.14.2 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.14.1 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.14.0 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.13.4 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.13.3 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.13.2 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.13.1 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.13.0 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.12.1 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.12.0 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.11.1 lib/authpwn_rails/facebook_session.rb
authpwn_rails-0.11.0 lib/authpwn_rails/facebook_session.rb