facebook and twitter both use omniauth and are saved as OmniauthServices
This commit is contained in:
parent
c489f49a25
commit
3d302f8db7
5 changed files with 29 additions and 28 deletions
21
Gemfile.lock
21
Gemfile.lock
|
|
@ -98,7 +98,6 @@ GEM
|
||||||
activesupport (= 3.0.1)
|
activesupport (= 3.0.1)
|
||||||
activesupport (3.0.1)
|
activesupport (3.0.1)
|
||||||
addressable (2.2.2)
|
addressable (2.2.2)
|
||||||
archive-tar-minitar (0.5.2)
|
|
||||||
arel (1.0.1)
|
arel (1.0.1)
|
||||||
activesupport (~> 3.0.0)
|
activesupport (~> 3.0.0)
|
||||||
aws (2.3.22)
|
aws (2.3.22)
|
||||||
|
|
@ -190,8 +189,7 @@ GEM
|
||||||
launchy (0.3.7)
|
launchy (0.3.7)
|
||||||
configuration (>= 0.0.5)
|
configuration (>= 0.0.5)
|
||||||
rake (>= 0.8.1)
|
rake (>= 0.8.1)
|
||||||
linecache19 (0.5.11)
|
linecache (0.43)
|
||||||
ruby_core_source (>= 0.1.4)
|
|
||||||
mail (2.2.7)
|
mail (2.2.7)
|
||||||
activesupport (>= 2.3.6)
|
activesupport (>= 2.3.6)
|
||||||
mime-types
|
mime-types
|
||||||
|
|
@ -305,19 +303,14 @@ GEM
|
||||||
rspec-expectations (~> 2.0.1)
|
rspec-expectations (~> 2.0.1)
|
||||||
rspec-rails (2.0.1)
|
rspec-rails (2.0.1)
|
||||||
rspec (~> 2.0.0)
|
rspec (~> 2.0.0)
|
||||||
ruby-debug-base19 (0.11.24)
|
ruby-debug (0.10.3)
|
||||||
columnize (>= 0.3.1)
|
columnize (>= 0.1)
|
||||||
linecache19 (>= 0.5.11)
|
ruby-debug-base (~> 0.10.3.0)
|
||||||
ruby_core_source (>= 0.1.4)
|
ruby-debug-base (0.10.3)
|
||||||
ruby-debug19 (0.11.6)
|
linecache (>= 0.3)
|
||||||
columnize (>= 0.3.1)
|
|
||||||
linecache19 (>= 0.5.11)
|
|
||||||
ruby-debug-base19 (>= 0.11.19)
|
|
||||||
ruby-openid (2.1.8)
|
ruby-openid (2.1.8)
|
||||||
ruby-openid-apps-discovery (1.2.0)
|
ruby-openid-apps-discovery (1.2.0)
|
||||||
ruby-openid (>= 2.1.7)
|
ruby-openid (>= 2.1.7)
|
||||||
ruby_core_source (0.1.4)
|
|
||||||
archive-tar-minitar (>= 0.5.2)
|
|
||||||
rubyntlm (0.1.1)
|
rubyntlm (0.1.1)
|
||||||
rubyzip (0.9.4)
|
rubyzip (0.9.4)
|
||||||
selenium-webdriver (0.0.29)
|
selenium-webdriver (0.0.29)
|
||||||
|
|
@ -385,7 +378,7 @@ DEPENDENCIES
|
||||||
roxml!
|
roxml!
|
||||||
rspec (>= 2.0.0)
|
rspec (>= 2.0.0)
|
||||||
rspec-rails (>= 2.0.0)
|
rspec-rails (>= 2.0.0)
|
||||||
ruby-debug19
|
ruby-debug
|
||||||
sprinkle!
|
sprinkle!
|
||||||
thin
|
thin
|
||||||
twitter
|
twitter
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,25 @@ class OmniauthServicesController < ApplicationController
|
||||||
def create
|
def create
|
||||||
auth = request.env['omniauth.auth']
|
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."
|
flash[:notice] = "Authentication successful."
|
||||||
redirect_to omniauth_services_url
|
redirect_to omniauth_services_url
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,7 @@ class StatusMessagesController < ApplicationController
|
||||||
|
|
||||||
if params[:status_message][:public] == '1'
|
if params[:status_message][:public] == '1'
|
||||||
current_user.post_to_twitter(message)
|
current_user.post_to_twitter(message)
|
||||||
if logged_into_fb?
|
current_user.post_to_facebook(message)
|
||||||
current_user.post_to_facebook(message, @access_token)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@status_message = current_user.post(:status_message, data)
|
@status_message = current_user.post(:status_message, data)
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,6 @@
|
||||||
= service.nickname
|
= service.nickname
|
||||||
= link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete
|
= link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete
|
||||||
|
|
||||||
= link_to "Connect to twitter", "/auth/twitter"
|
%h4= link_to "Connect to twitter", "/auth/twitter"
|
||||||
= link_to "Connect to facebook", "/auth/facebook"
|
%h4= link_to "Connect to facebook", "/auth/facebook"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ cross_server:
|
||||||
deploy_to: '/usr/local/app/diaspora'
|
deploy_to: '/usr/local/app/diaspora'
|
||||||
user: 'root'
|
user: 'root'
|
||||||
repo: 'git://github.com/diaspora/diaspora.git'
|
repo: 'git://github.com/diaspora/diaspora.git'
|
||||||
branch: 'master'
|
branch: 'twitter'
|
||||||
default_env: 'development'
|
default_env: 'development'
|
||||||
servers:
|
servers:
|
||||||
tom:
|
tom:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue