Skip to content

Commit

Permalink
attempt to load ruby-openid. if it's not there, #open_id? always retu…
Browse files Browse the repository at this point in the history
…rns false. also fix the README a bit

git-svn-id: http://svn.rubyonrails.org/rails/plugins/open_id_authentication@6251 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
rick committed Feb 27, 2007
1 parent abc9f9a commit 913f113
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
21 changes: 15 additions & 6 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,26 @@ app/controllers/session_controller.rb
protected
def password_authentication(name, password)
if @current_user = @account.users.find_by_name_and_password(params[:name], params[:password])
successful_authentication
successful_login
else
failed_authentication "Sorry, that username/password doesn't work"
failed_login "Sorry, that username/password doesn't work"
end
end

def open_id_authentication(identity_url)
authenticate_with_open_id(identity_url) do |status, identity_url|
case status
when :missing
failed_authentication "Sorry, the OpenID server couldn't be found"
failed_login "Sorry, the OpenID server couldn't be found"
when :canceled
failed_authentication "OpenID verification was canceled"
failed_login "OpenID verification was canceled"
when :failed
failed_authentication "Sorry, the OpenID verification failed"
failed_login "Sorry, the OpenID verification failed"
when :successful
if @current_user = @account.users.find_by_identity_url(identity_url)
successful_login
else
failed_authentication "Sorry, no user by that identity URL exists"
failed_login "Sorry, no user by that identity URL exists"
end
end
end
Expand All @@ -83,6 +83,15 @@ app/controllers/session_controller.rb
flash[:error] = message
redirect_to(new_session_url)
end

# Set #root_url if your root url has a different named route.
#
# map.home '', :controller => ..., :action => ...
#
# Otherwise, name the route 'root' and leave this method out.
def root_url
home_url
end
end


Expand Down
7 changes: 7 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
begin
gem 'ruby-openid'
require 'openid'
rescue LoadError
puts "Install the ruby-openid gem to enable OpenID support"
end

ActionController::Base.send :include, OpenIdAuthentication
2 changes: 1 addition & 1 deletion lib/open_id_authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module OpenIdAuthentication
protected
# OpenIDs are expected to begin with http:// or https://
def open_id?(user_name) #:doc:
user_name =~ /^https?:\/\//i || params[:open_id_complete]
(Object.const_defined?(:OpenID) && user_name =~ /^https?:\/\//i) || params[:open_id_complete]
end

def authenticate_with_open_id(identity_url, &block) #:doc:
Expand Down

0 comments on commit 913f113

Please sign in to comment.