Class: Devise::FacebookConsumerController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Devise::FacebookConsumerController
- Includes:
- Controllers::InternalHelpers, DeviseOauth2Facebook::FacebookConsumerHelper
- Defined in:
- app/controllers/devise/facebook_consumer_controller.rb
Instance Method Summary collapse
Methods included from DeviseOauth2Facebook::FacebookConsumerHelper
Instance Method Details
#auth ⇒ Object
5 6 7 8 |
# File 'app/controllers/devise/facebook_consumer_controller.rb', line 5 def auth url = send("#{resource_name}_fb_callback_url".to_sym) redirect_to facebook_client..(:redirect_uri => url , :scope => Devise.) end |
#callback ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/devise/facebook_consumer_controller.rb', line 10 def callback # if resource_class.respond_to?(:serialize_into_cookie) # User.first.remember_me! # cookies.signed["remember_#{resource_name}_token"] = { # :value => User.first.class.serialize_into_cookie(User.first), # :expires => User.first.remember_expires_at, # :path => "/" # } # end # sign_in_and_redirect(resource_name, User.first) # set_flash_message :notice, :signed_in # return url = send("#{resource_name}_fb_callback_url".to_sym) client = facebook_client client..process_callback(params[:code], :redirect_uri => url) token = client.access_token fb_user = client.selection.me.info! # Rails.logger.info "FB USER:" # Rails.logger.info fb_user.inspect resource = resource_class.find_with_facebook_user(fb_user, token) unless resource resource = resource_class.create_with_facebook_user(fb_user, token) end if resource_class.respond_to?(:serialize_into_cookie) resource.remember_me! .signed["remember_#{resource_name}_token"] = { :value => resource.class.(resource), :expires => resource.remember_expires_at, :path => "/" } end :notice, :signed_in sign_in_and_redirect(resource_name, resource) end |