Ticket #8033: open_id_cleanup.diff
| File open_id_cleanup.diff, 4.3 kB (added by monki, 1 year ago) |
|---|
-
test/open_id_authentication_test.rb
old new 28 28 end 29 29 30 30 def test_authentication_should_fail_when_the_identity_server_times_out 31 @controller.stubs(:open_id_consumer).returns(stub(:begin => Proc.new { raise Timeout::Error}))31 @controller.stubs(:open_id_consumer).returns(stub(:begin => Proc.new { raise(Timeout::Error, "Identity server timed out") })) 32 32 33 33 @controller.send(:authenticate_with_open_id, "http://someone.example.com") do |result, identity_url| 34 34 assert result.missing? -
lib/open_id_authentication.rb
old new 40 40 def message 41 41 ERROR_MESSAGES[@code] 42 42 end 43 44 attr_reader :code 43 45 end 44 46 45 47 def self.normalize_url(url) -
README
old new 45 45 app/views/sessions/new.erb 46 46 47 47 <% form_tag(session_url) do %> 48 <p style="color: red"><%= flash[:error] %></ 49 48 50 <p> 49 51 <label for="name">Username:</label> 50 52 <%= text_field_tag "name" %> … … 65 67 </p> 66 68 67 69 <p> 68 <%= submit_tag 'Sign in', :disable_with => "Signing in …" %>70 <%= submit_tag 'Sign in', :disable_with => "Signing in..." %> 69 71 </p> 70 72 <% end %> 71 73 … … 82 84 83 85 protected 84 86 def password_authentication(name, password) 85 if @current_user = @account.users.authenticate(params[:name], params[:password])87 if @current_user = User.authenticate(params[:name], params[:password]) 86 88 successful_login 87 89 else 88 90 failed_login "Sorry, that username/password doesn't work" … … 91 93 92 94 def open_id_authentication 93 95 authenticate_with_open_id do |result, identity_url| 94 case result 96 case result.code 95 97 when :missing 96 98 failed_login "Sorry, the OpenID server couldn't be found" 97 99 when :canceled … … 99 101 when :failed 100 102 failed_login "Sorry, the OpenID verification failed" 101 103 when :successful 102 if @current_user = @account.users.find_by_identity_url(identity_url)104 if @current_user = User.find_by_identity_url(identity_url) 103 105 successful_login 104 106 else 105 failed_login "Sorry, no user by that identity URL exists (#{identity_url})" )107 failed_login "Sorry, no user by that identity URL exists (#{identity_url})" 106 108 end 107 109 end 108 110 end … … 128 130 129 131 def open_id_authentication 130 132 authenticate_with_open_id do |result, identity_url| 131 if result.successful? && @current_user = @account.users.find_by_identity_url(identity_url)133 if result.successful? && @current_user = User.find_by_identity_url(identity_url) 132 134 successful_login 133 135 else 134 failed_login(result.message || "Sorry, no user by that identity URL exists (#{identity_url})" )136 failed_login(result.message || "Sorry, no user by that identity URL exists (#{identity_url})" 135 137 end 136 138 end 137 139 end … … 149 151 # Be sure to yield registration, a third argument in the #authenticate_with_open_id block. 150 152 authenticate_with_open_id(identity_url, 151 153 :required => [ :nickname, :email ], 152 :optional => :fullname) do | status, identity_url, registration|153 case status154 :optional => :fullname) do |result, identity_url, registration| 155 case result.code 154 156 when :missing 155 157 failed_login "Sorry, the OpenID server couldn't be found" 156 158 when :canceled … … 158 160 when :failed 159 161 failed_login "Sorry, the OpenID verification failed" 160 162 when :successful 161 if @current_user = @account.users.find_by_identity_url(identity_url)163 if @current_user = User.find_by_identity_url(identity_url) 162 164 assign_registration_attributes!(registration) 163 165 164 166 if current_user.save