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
|
# File 'app/controllers/devise/facebook_consumer_controller.rb', line 15
def callback
url = send("#{resource_name}_fb_callback_url".to_sym)
client = facebook_client
client.authorization.process_callback(params[:code], :redirect_uri => url)
token = client.access_token
fb_user = client.selection.me.info!
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!
cookies.signed["remember_#{resource_name}_token"] = {
:value => resource.class.serialize_into_cookie(resource),
:expires => resource.remember_expires_at,
:path => "/"
}
end
set_flash_message :notice, :signed_in
if Devise.facebook_canvas_app
sign_in(resource_name, resource)
redirect_to Devise.facebook_canvas_url
else
sign_in_and_redirect(resource_name, resource)
end
end
|