facebook and twitter both use omniauth and are saved as OmniauthServices

This commit is contained in:
danielvincent 2010-10-25 14:49:55 -07:00
parent c489f49a25
commit 3d302f8db7
5 changed files with 29 additions and 28 deletions

View file

@ -98,7 +98,6 @@ GEM
activesupport (= 3.0.1)
activesupport (3.0.1)
addressable (2.2.2)
archive-tar-minitar (0.5.2)
arel (1.0.1)
activesupport (~> 3.0.0)
aws (2.3.22)
@ -190,8 +189,7 @@ GEM
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
linecache (0.43)
mail (2.2.7)
activesupport (>= 2.3.6)
mime-types
@ -305,19 +303,14 @@ GEM
rspec-expectations (~> 2.0.1)
rspec-rails (2.0.1)
rspec (~> 2.0.0)
ruby-debug-base19 (0.11.24)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby-debug (0.10.3)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.3.0)
ruby-debug-base (0.10.3)
linecache (>= 0.3)
ruby-openid (2.1.8)
ruby-openid-apps-discovery (1.2.0)
ruby-openid (>= 2.1.7)
ruby_core_source (0.1.4)
archive-tar-minitar (>= 0.5.2)
rubyntlm (0.1.1)
rubyzip (0.9.4)
selenium-webdriver (0.0.29)
@ -385,7 +378,7 @@ DEPENDENCIES
roxml!
rspec (>= 2.0.0)
rspec-rails (>= 2.0.0)
ruby-debug19
ruby-debug
sprinkle!
thin
twitter

View file

@ -13,15 +13,25 @@ class OmniauthServicesController < ApplicationController
def create
auth = request.env['omniauth.auth']
puts auth.inspect
provider = auth['provider']
user = auth['user_info']
if provider == 'twitter'
access_token = auth['extra']['access_token']
current_user.services.create(:nickname => user['nickname'],
:access_token => access_token.token,
:access_secret => access_token.secret,
:provider => provider,
:uid => auth['uid'])
elsif provider == 'facebook'
current_user.services.create(:nickname => user['nickname'],
:access_token => auth['credentials']['token'],
:provider => provider,
:uid => auth['uid'])
end
access_token = auth['extra']['access_token']
user = auth['user_info']
current_user.services.create(:nickname => user['nickname'],
:access_token => access_token.token,
:access_secret => access_token.secret,
:provider => auth['provider'],
:uid => auth['uid'])
flash[:notice] = "Authentication successful."
redirect_to omniauth_services_url
end

View file

@ -14,9 +14,7 @@ class StatusMessagesController < ApplicationController
if params[:status_message][:public] == '1'
current_user.post_to_twitter(message)
if logged_into_fb?
current_user.post_to_facebook(message, @access_token)
end
current_user.post_to_facebook(message)
end
@status_message = current_user.post(:status_message, data)

View file

@ -14,6 +14,6 @@
= service.nickname
= link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete
= link_to "Connect to twitter", "/auth/twitter"
= link_to "Connect to facebook", "/auth/facebook"
%h4= link_to "Connect to twitter", "/auth/twitter"
%h4= link_to "Connect to facebook", "/auth/facebook"

View file

@ -6,7 +6,7 @@ cross_server:
deploy_to: '/usr/local/app/diaspora'
user: 'root'
repo: 'git://github.com/diaspora/diaspora.git'
branch: 'master'
branch: 'twitter'
default_env: 'development'
servers:
tom: