merge 19889:20181 of rails_port into the openID branch
authorKai Krueger <kakrueger@gmail.com>
Sat, 27 Feb 2010 11:21:15 +0000 (11:21 +0000)
committerKai Krueger <kakrueger@gmail.com>
Sat, 27 Feb 2010 11:21:15 +0000 (11:21 +0000)
merge conflicts with the remember_me functionality

27 files changed:
app/controllers/user_controller.rb
app/models/user.rb
app/views/user/account.html.erb
app/views/user/login.html.erb
app/views/user/new.html.erb
config/environment.rb
config/locales/en.yml
db/migrate/050_add_open_id_authentication_tables.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/CHANGELOG [new file with mode: 0644]
vendor/plugins/open_id_authentication/README [new file with mode: 0644]
vendor/plugins/open_id_authentication/Rakefile [new file with mode: 0644]
vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/generators/open_id_authentication_tables/templates/migration.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/templates/migration.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/generators/upgrade_open_id_authentication_tables/upgrade_open_id_authentication_tables_generator.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/init.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/lib/open_id_authentication.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/lib/open_id_authentication/association.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/lib/open_id_authentication/nonce.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/lib/open_id_authentication/request.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/lib/open_id_authentication/timeout_fixes.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/tasks/open_id_authentication_tasks.rake [new file with mode: 0644]
vendor/plugins/open_id_authentication/test/normalize_test.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/test/status_test.rb [new file with mode: 0644]
vendor/plugins/open_id_authentication/test/test_helper.rb [new file with mode: 0644]

index c181da305862f81bdd721fb9098d154f98e46b90..97e184b5943cef9269668e13520893f6867b9375 100644 (file)
@@ -24,6 +24,18 @@ class UserController < ApplicationController
     if Acl.find_by_address(request.remote_ip, :conditions => {:k => "no_account_creation"})
       render :action => 'new'
     else
+         #The redirect from the OpenID provider reenters here again 
+      #and we need to pass the parameters through to the  
+      #open_id_authentication function a second time 
+      if params[:open_id_complete] 
+        openid_verify('', true) 
+        #We have set the user.openid_url to nil beforehand. If it hasn't 
+        #been set to a new valid openid_url, it means the openid couldn't be validated 
+        if @user.nil? or @user.openid_url.nil? 
+          render :action => 'new' 
+          return 
+        end   
+      else
       @user = User.new(params[:user])
 
       @user.visible = true
@@ -31,6 +43,52 @@ class UserController < ApplicationController
       @user.description = "" if @user.description.nil?
       @user.creation_ip = request.remote_ip
       @user.languages = request.user_preferred_languages
+        #Set the openid_url to nil as for one it is used 
+        #to check if the openid could be validated and secondly 
+        #to not get dupplicate conflicts for an empty openid  
+        @user.openid_url = nil
+
+if (!params[:user][:openid_url].nil? and params[:user][:openid_url].length > 0)
+                 if @user.pass_crypt.length == 0 
+            #if the password is empty, but we have a openid 
+            #then generate a random passowrd to disable 
+            #loging in via password 
+            @user.pass_crypt = ActiveSupport::SecureRandom.base64(16) 
+            @user.pass_crypt_confirmation = @user.pass_crypt 
+          end
+                 #Validate all of the other fields before
+                 #redirecting to the openid provider
+                 if !@user.valid?
+                       render :action => 'new'
+                 else            
+                       #TODO: Is it a problem to store the user variable with respect to password safty in the session variables?
+                       #Store the user variable in the session for it to be accessible when redirecting back from the openid provider
+                       session[:new_usr] = @user
+                       begin
+                         @norm_openid_url = OpenIdAuthentication.normalize_identifier(params[:user][:openid_url])
+                       rescue
+                         flash.now[:error] = t 'user.login.openid invalid'
+                         render :action => 'new'
+                         return
+                       end
+                       #Verify that the openid provided is valid and that the user is the owner of the id
+                       openid_verify(@norm_openid_url, true)
+                       #openid_verify can return in two ways:
+                       #Either it returns with a redirect to the openid provider who then freshly
+                       #redirects bac