Connecting access_token records with existing users #45

Open
wants to merge 3 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+307 −10
Split
View
@@ -0,0 +1,244 @@
+--- !ruby/object:Gem::Specification
+name: authlogic-connect
+version: !ruby/object:Gem::Version
+ hash: 19
+ prerelease: false
+ segments:
+ - 0
+ - 0
+ - 18
+ version: 0.0.18
+platform: ruby
+authors:
+- Lance Pollard
+autorequire:
+bindir: bin
+cert_chain: []
+
+date: 2010-07-14 00:00:00 -07:00
+default_executable:
+dependencies:
+- !ruby/object:Gem::Dependency
+ name: activesupport
+ prerelease: false
+ requirement: &id001 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 15
+ segments:
+ - 2
+ - 1
+ - 2
+ version: 2.1.2
+ type: :runtime
+ version_requirements: *id001
+- !ruby/object:Gem::Dependency
+ name: activerecord
+ prerelease: false
+ requirement: &id002 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 15
+ segments:
+ - 2
+ - 1
+ - 2
+ version: 2.1.2
+ type: :runtime
+ version_requirements: *id002
+- !ruby/object:Gem::Dependency
+ name: json
+ prerelease: false
+ requirement: &id003 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+ type: :runtime
+ version_requirements: *id003
+- !ruby/object:Gem::Dependency
+ name: ruby-openid
+ prerelease: false
+ requirement: &id004 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+ type: :runtime
+ version_requirements: *id004
+- !ruby/object:Gem::Dependency
+ name: rack-openid
+ prerelease: false
+ requirement: &id005 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 21
+ segments:
+ - 0
+ - 2
+ - 1
+ version: 0.2.1
+ type: :runtime
+ version_requirements: *id005
+- !ruby/object:Gem::Dependency
+ name: oauth
+ prerelease: false
+ requirement: &id006 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+ type: :runtime
+ version_requirements: *id006
+- !ruby/object:Gem::Dependency
+ name: oauth2
+ prerelease: false
+ requirement: &id007 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+ type: :runtime
+ version_requirements: *id007
+- !ruby/object:Gem::Dependency
+ name: authlogic
+ prerelease: false
+ requirement: &id008 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+ type: :runtime
+ version_requirements: *id008
+description: Oauth and OpenID made dead simple
+email: lancejpollard@gmail.com
+executables: []
+
+extensions: []
+
+extra_rdoc_files: []
+
+files:
+- README.markdown
+- Rakefile
+- init.rb
+- MIT-LICENSE
+- lib/authlogic-connect.rb
+- lib/authlogic_connect/access_token.rb
+- lib/authlogic_connect/authlogic_connect.rb
+- lib/authlogic_connect/callback_filter.rb
+- lib/authlogic_connect/common/session.rb
+- lib/authlogic_connect/common/state.rb
+- lib/authlogic_connect/common/user.rb
+- lib/authlogic_connect/common/variables.rb
+- lib/authlogic_connect/common.rb
+- lib/authlogic_connect/engine.rb
+- lib/authlogic_connect/ext.rb
+- lib/authlogic_connect/oauth/helper.rb
+- lib/authlogic_connect/oauth/process.rb
+- lib/authlogic_connect/oauth/session.rb
+- lib/authlogic_connect/oauth/state.rb
+- lib/authlogic_connect/oauth/tokens/aol_token.rb
+- lib/authlogic_connect/oauth/tokens/facebook_token.rb
+- lib/authlogic_connect/oauth/tokens/foursquare_token.rb
+- lib/authlogic_connect/oauth/tokens/get_satisfaction_token.rb
+- lib/authlogic_connect/oauth/tokens/github_token.rb
+- lib/authlogic_connect/oauth/tokens/google_token.rb
+- lib/authlogic_connect/oauth/tokens/linked_in_token.rb
+- lib/authlogic_connect/oauth/tokens/meetup_token.rb
+- lib/authlogic_connect/oauth/tokens/myspace_token.rb
+- lib/authlogic_connect/oauth/tokens/netflix_token.rb
+- lib/authlogic_connect/oauth/tokens/oauth_token.rb
+- lib/authlogic_connect/oauth/tokens/ohloh_token.rb
+- lib/authlogic_connect/oauth/tokens/opensocial_token.rb
+- lib/authlogic_connect/oauth/tokens/twitter_token.rb
+- lib/authlogic_connect/oauth/tokens/vimeo_token.rb
+- lib/authlogic_connect/oauth/tokens/yahoo_token.rb
+- lib/authlogic_connect/oauth/user.rb
+- lib/authlogic_connect/oauth/variables.rb
+- lib/authlogic_connect/oauth.rb
+- lib/authlogic_connect/openid/process.rb
+- lib/authlogic_connect/openid/session.rb
+- lib/authlogic_connect/openid/state.rb
+- lib/authlogic_connect/openid/tokens/aol_token.rb
+- lib/authlogic_connect/openid/tokens/blogger_token.rb
+- lib/authlogic_connect/openid/tokens/flickr_token.rb
+- lib/authlogic_connect/openid/tokens/my_openid_token.rb
+- lib/authlogic_connect/openid/tokens/openid_token.rb
+- lib/authlogic_connect/openid/user.rb
+- lib/authlogic_connect/openid/variables.rb
+- lib/authlogic_connect/openid.rb
+- lib/authlogic_connect/rack_state.rb
+- lib/open_id_authentication.rb
+- rails/init.rb
+- test/controllers/test_users_controller.rb
+- test/database.yml
+- test/libs/database.rb
+- test/libs/user.rb
+- test/libs/user_session.rb
+- test/test_helper.rb
+- test/test_oauth.rb
+- test/test_openid.rb
+- test/test_user.rb
+has_rdoc: true
+homepage: http://github.com/viatropos/authlogic-connect
+licenses: []
+
+post_install_message:
+rdoc_options: []
+
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+required_rubygems_version: !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+requirements: []
+
+rubyforge_project: authlogic-connect
+rubygems_version: 1.3.7
+signing_key:
+specification_version: 3
+summary: "Authlogic Connect: Oauth and OpenID made dead simple"
+test_files: []
+
View
0 MIT-LICENSE 100755 → 100644
No changes.
View
@@ -2,35 +2,48 @@ README.markdown
Rakefile
init.rb
MIT-LICENSE
+lib/authlogic-connect.rb
lib/authlogic_connect
+lib/authlogic_connect/access_token.rb
+lib/authlogic_connect/authlogic_connect.rb
+lib/authlogic_connect/callback_filter.rb
lib/authlogic_connect/common
lib/authlogic_connect/common/session.rb
+lib/authlogic_connect/common/state.rb
lib/authlogic_connect/common/user.rb
lib/authlogic_connect/common/variables.rb
lib/authlogic_connect/common.rb
+lib/authlogic_connect/engine.rb
+lib/authlogic_connect/ext.rb
lib/authlogic_connect/oauth
lib/authlogic_connect/oauth/helper.rb
lib/authlogic_connect/oauth/process.rb
lib/authlogic_connect/oauth/session.rb
+lib/authlogic_connect/oauth/state.rb
lib/authlogic_connect/oauth/tokens
-lib/authlogic_connect/oauth/tokens/delicious_token.rb
+lib/authlogic_connect/oauth/tokens/aol_token.rb
lib/authlogic_connect/oauth/tokens/facebook_token.rb
lib/authlogic_connect/oauth/tokens/foursquare_token.rb
lib/authlogic_connect/oauth/tokens/get_satisfaction_token.rb
+lib/authlogic_connect/oauth/tokens/github_token.rb
lib/authlogic_connect/oauth/tokens/google_token.rb
+lib/authlogic_connect/oauth/tokens/linked_in_token.rb
+lib/authlogic_connect/oauth/tokens/meetup_token.rb
lib/authlogic_connect/oauth/tokens/myspace_token.rb
+lib/authlogic_connect/oauth/tokens/netflix_token.rb
lib/authlogic_connect/oauth/tokens/oauth_token.rb
+lib/authlogic_connect/oauth/tokens/ohloh_token.rb
lib/authlogic_connect/oauth/tokens/opensocial_token.rb
-lib/authlogic_connect/oauth/tokens/photobucket_token.rb
-lib/authlogic_connect/oauth/tokens/smug_mug_token.rb
lib/authlogic_connect/oauth/tokens/twitter_token.rb
lib/authlogic_connect/oauth/tokens/vimeo_token.rb
lib/authlogic_connect/oauth/tokens/yahoo_token.rb
lib/authlogic_connect/oauth/user.rb
lib/authlogic_connect/oauth/variables.rb
lib/authlogic_connect/oauth.rb
lib/authlogic_connect/openid
+lib/authlogic_connect/openid/process.rb
lib/authlogic_connect/openid/session.rb
+lib/authlogic_connect/openid/state.rb
lib/authlogic_connect/openid/tokens
lib/authlogic_connect/openid/tokens/aol_token.rb
lib/authlogic_connect/openid/tokens/blogger_token.rb
@@ -40,6 +53,16 @@ lib/authlogic_connect/openid/tokens/openid_token.rb
lib/authlogic_connect/openid/user.rb
lib/authlogic_connect/openid/variables.rb
lib/authlogic_connect/openid.rb
-lib/oauth_callback_filter.rb
-lib/token.rb
+lib/authlogic_connect/rack_state.rb
+lib/open_id_authentication.rb
rails/init.rb
+test/controllers
+test/controllers/test_users_controller.rb
+test/libs
+test/libs/database.rb
+test/libs/user.rb
+test/libs/user_session.rb
+test/test_helper.rb
+test/test_oauth.rb
+test/test_openid.rb
+test/test_user.rb
View
0 README.markdown 100755 → 100644
No changes.
View
2 Rakefile 100755 → 100644
@@ -6,7 +6,7 @@ require 'rake/gempackagetask'
spec = Gem::Specification.new do |s|
s.name = "authlogic-connect"
s.author = "Lance Pollard"
- s.version = "0.0.6"
+ s.version = "0.0.18"
s.summary = "Authlogic Connect: Oauth and OpenID made dead simple"
s.homepage = "http://github.com/viatropos/authlogic-connect"
s.email = "lancejpollard@gmail.com"
View
0 init.rb 100755 → 100644
No changes.
View
0 lib/authlogic-connect.rb 100755 → 100644
No changes.
View
No changes.
View
No changes.
View
No changes.
View
0 lib/authlogic_connect/common.rb 100755 → 100644
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
0 lib/authlogic_connect/engine.rb 100755 → 100644
No changes.
View
0 lib/authlogic_connect/ext.rb 100755 → 100644
No changes.
View
0 lib/authlogic_connect/oauth.rb 100755 → 100644
No changes.
View
No changes.
View
@@ -13,8 +13,10 @@ def validate_by_oauth
def start_oauth
save_oauth_session
authorize_url = token_class.authorize_url(auth_callback_url) do |request_token|
+ request_token.display = "popup"
save_auth_session_token(request_token) # only for oauth version 1
end
+ puts "4 AAAAAAAAAA ----------------- authorize_url #{authorize_url}"
auth_controller.redirect_to authorize_url
end
View
@@ -39,12 +39,40 @@ def complete_oauth_transaction
# this is searching with User.find ...
# attempted_record is part of AuthLogic
hash = oauth_token_and_secret
+ puts "////////////////////////// OAUTH"
+ puts "////////////////////////// OAUTH #{hash}"
+ puts "////////////////////////// OAUTH.inspect #{hash.inspect}"
+ puts "////////////////////////// hash[:key] #{hash[:key]}"
+ puts "////////////////////////// hash[:token] #{hash[:token]}"
token = token_class.find_by_key_or_token(hash[:key], hash[:token], :include => [:user]) # some weird error if I leave out the include)
if token
self.attempted_record = token.user
elsif auto_register?
self.attempted_record = klass.new
self.attempted_record.access_tokens << token_class.new(hash)
+
+ puts "////////////// FACEBOOK TOKEN??? #{self.attempted_record.get_token(:facebook)}"
+ puts "////////////// FACEBOOK TOKEN??? #{self.attempted_record.get_token(:facebook).inspect}"
+ # If it's a facebook token lets look up the users email address
+ if self.attempted_record.has_token?(:facebook)
+ self.attempted_record.active_token = self.attempted_record.get_token(:facebook)
+ facebook = JSON.parse(self.attempted_record.active_token.get("/me"))
+ puts "////////////// FACEBOOK DETAILS #{facebook.inspect}"
+ puts "////////////// FACEBOOK EMAIL #{facebook[:email]}"
+ if facebook[:email]
+ existing_user = klass.find_by_email(facebook[:email])
+ puts "////////////// FACEBOOK DETAILS YES YES YES YES #{existing_user} #{existing_user.inspect}"
+ if existing_user
+ # It would be nice to place this app specific code somewhere else
+ self.attempted_record = existing_user
+ self.attempted_record.access_tokens << token_class.new(hash)
+ end
+ end
+ self.attempted_record.first_name = facebook[:first_name] if !facebook[:first_name].nil? and !self.attempted_record.first_name.nil?
+ self.attempted_record.last_name = facebook[:last_name] if !facebook[:last_name].nil? and !self.attempted_record.last_name.nil?
+ end
+
+
self.attempted_record.save
else
auth_session[:_key] = hash[:key]
View
No changes.
View
No changes.
No changes.
No changes.
View
No changes.
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
No changes.
View
@@ -2,7 +2,7 @@ class TwitterToken < OauthToken
key :user_id
- settings "http://api.twitter.com",
+ settings "https://api.twitter.com",
:authorize_url => "http://api.twitter.com/oauth/authenticate"
end
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
0 lib/authlogic_connect/openid.rb 100755 → 100644
No changes.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
No changes.
View
No changes.
No changes.
View
No changes.
View
No changes.
View
No changes.
View
0 lib/open_id_authentication.rb 100755 → 100644
No changes.
Oops, something went wrong.