diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index dae268f..aa5d22b 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -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 diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 83cb405..cf51ba9 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -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'