]> source.dussan.org Git - redmine.git/commitdiff
Fixed a bug in the OpenID login when a user signed up with OpenID but hasn't
authorEric Davis <edavis@littlestreamsoftware.com>
Fri, 20 Feb 2009 00:16:45 +0000 (00:16 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Fri, 20 Feb 2009 00:16:45 +0000 (00:16 +0000)
been activated yet.

When logging in the user would come back to the login page with the back_url
of My Page.  This was caused by open_id_authenticate sending the user to My Page
and My Page redirecting the user back to the login page because they haven't
been activated.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2482 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/account_controller.rb
test/functional/account_controller_test.rb

index dae268f201fc5af3422246853cb15d1ed741e347..aa5d22b460761931cb3281f0d676a7f82288d637 100644 (file)
@@ -209,7 +209,11 @@ private
           end          
         else
           # Existing record
-          successful_authentication(user)
+          if user.active?
+            successful_authentication(user)
+          else
+            account_pending
+          end
         end
       end
     end
@@ -269,10 +273,14 @@ private
     if user.save
       # Sends an email to the administrators
       Mailer.deliver_account_activation_request(user)
-      flash[:notice] = l(:notice_account_pending)
-      redirect_to :action => 'login'
+      account_pending
     else
       yield if block_given?
     end
   end
+
+  def account_pending
+    flash[:notice] = l(:notice_account_pending)
+    redirect_to :action => 'login'
+  end
 end
index 83cb40558b94c3cfaac60f5ac5c3bb736362a5cb..cf51ba93c8f2277abec34f4716cb9163b2baf3a5 100644 (file)
@@ -80,6 +80,21 @@ class AccountControllerTest < Test::Unit::TestCase
     assert_redirected_to 'my/page'
   end
 
+  def test_login_with_openid_for_existing_non_active_user
+    Setting.self_registration = '2'
+    Setting.openid = '1'
+    existing_user = User.new(:firstname => 'Cool',
+                             :lastname => 'User',
+                             :mail => 'user@somedomain.com',
+                             :identity_url => 'http://openid.example.com/good_user',
+                             :status => User::STATUS_REGISTERED)
+    existing_user.login = 'cool_user'
+    assert existing_user.save!
+
+    post :login, :openid_url => existing_user.identity_url
+    assert_redirected_to 'login'
+  end
+
   def test_login_with_openid_with_new_user_created
     Setting.self_registration = '3'
     Setting.openid = '1'