]> source.dussan.org Git - redmine.git/commitdiff
Prevent registration via OpenID if self registration is off. #699
authorEric Davis <edavis@littlestreamsoftware.com>
Wed, 11 Feb 2009 19:07:41 +0000 (19:07 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Wed, 11 Feb 2009 19:07:41 +0000 (19:07 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2448 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 4bfe562c60e8276a48b67d46098f0dbaf651f5cf..9f5200ee38044623a3fb8d9fb31431c752c2fd7b 100644 (file)
@@ -183,6 +183,9 @@ private
       if result.successful?
         user = User.find_or_initialize_by_identity_url(identity_url)
         if user.new_record?
+          # Self-registration off
+          redirect_to(home_url) && return unless Setting.self_registration?
+
           # Create on the fly
           user.login = registration['nickname'] unless registration['nickname'].nil?
           user.mail = registration['email'] unless registration['email'].nil?
index edca1d2f1015cb5b517b80baef8ca1a33f987ba6..aec626a2f789601f9a73b73a50f1fa095eda6492 100644 (file)
@@ -86,7 +86,15 @@ class AccountControllerTest < Test::Unit::TestCase
     assert_equal 'Cool', user.firstname
     assert_equal 'User', user.lastname
   end
-  
+
+  def test_login_with_openid_with_new_user_and_self_registration_off
+    Setting.self_registration = '0'
+    post :login, :openid_url => 'http://openid.example.com/good_user'
+    assert_redirected_to home_url
+    user = User.find_by_login('cool_user')
+    assert ! user
+  end
+
   def test_login_with_openid_with_new_user_created_with_email_activation_should_have_a_token
     Setting.self_registration = '1'
     post :login, :openid_url => 'http://openid.example.com/good_user'