Skip to content
Browse files

updated rails to use gem, to newest open-id-auth plugin

  • Loading branch information...
1 parent 210df74 commit cef4104852f65248a5575340d6c5e195ac2d4448 Holden Thomas committed Sep 24, 2009
View
5 app/models/user.rb
@@ -4,9 +4,10 @@ class User < ActiveRecord::Base
# optional, but if a user registers by openid, he should at least share his email-address with the app
c.validate_email_field = false
# fetch email by ax
- c.required_fields = ["http://axschema.org/contact/email"]
+ c.openid_required_fields = [:email,"http://axschema.org/contact/email"]
+ #c.required_fields = ["http://axschema.org/contact/email"]
# fetch email by sreg
- c.optional_fields = ["email"]
+ #c.optional_fields = ["email"]
end
private
View
6 config/environment.rb
@@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.1.2' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
@@ -25,8 +25,8 @@
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "aws-s3", :lib => "aws/s3"
- config.gem "authlogic", :version => '2.0.11'
- config.gem "authlogic-oid", :lib => "authlogic_openid", :version => '1.0.3'
+ config.gem "authlogic"
+ config.gem "authlogic-oid", :lib => "authlogic_openid"
# Only load the plugins named here, in the order given. By default, all plugins
# in vendor/plugins are loaded in alphabetical order.
View
9 vendor/plugins/open_id_authentication/lib/open_id_authentication.rb
@@ -6,7 +6,6 @@
require File.dirname(__FILE__) + '/open_id_authentication/association'
require File.dirname(__FILE__) + '/open_id_authentication/nonce'
require File.dirname(__FILE__) + '/open_id_authentication/db_store'
-require File.dirname(__FILE__) + '/open_id_authentication/mem_cache_store'
require File.dirname(__FILE__) + '/open_id_authentication/request'
require File.dirname(__FILE__) + '/open_id_authentication/timeout_fixes' if OpenID::VERSION == "2.0.4"
@@ -23,12 +22,10 @@ def self.store=(*store_option)
@@store = case store
when :db
OpenIdAuthentication::DbStore.new
- when :mem_cache
- OpenIdAuthentication::MemCacheStore.new(*parameters)
when :file
OpenID::Store::Filesystem.new(OPEN_ID_AUTHENTICATION_DIR)
else
- raise "Unknown store: #{store}"
+ store
end
end
@@ -145,7 +142,6 @@ def begin_open_id_authentication(identity_url, options = {})
open_id_request = open_id_consumer.begin(identity_url)
add_simple_registration_fields(open_id_request, options)
add_ax_fields(open_id_request, options)
-
redirect_to(open_id_redirect_url(open_id_request, return_to, method))
rescue OpenIdAuthentication::InvalidOpenId => e
yield Result[:invalid], identity_url, nil
@@ -159,6 +155,7 @@ def complete_open_id_authentication
params_with_path.delete(:format)
open_id_response = timeout_protection_from_identity_server { open_id_consumer.complete(params_with_path, requested_url) }
identity_url = normalize_identifier(open_id_response.display_identifier) if open_id_response.display_identifier
+
case open_id_response.status
when OpenID::Consumer::SUCCESS
profile_data = {}
@@ -169,6 +166,7 @@ def complete_open_id_authentication
profile_data.merge! data_response.from_success_response( open_id_response ).data
end
end
+
yield Result[:successful], identity_url, profile_data
when OpenID::Consumer::CANCEL
yield Result[:canceled], identity_url, nil
@@ -185,6 +183,7 @@ def open_id_consumer
def add_simple_registration_fields(open_id_request, fields)
sreg_request = OpenID::SReg::Request.new
+
# filter out AX identifiers (URIs)
required_fields = fields[:required].collect { |f| f.to_s unless f =~ /^https?:\/\// }.compact
optional_fields = fields[:optional].collect { |f| f.to_s unless f =~ /^https?:\/\// }.compact

0 comments on commit cef4104

Please sign in to comment.
Something went wrong with that request. Please try again.