]> source.dussan.org Git - redmine.git/commitdiff
Fix 500 errors with a POST request that requires a login. #4216
authorEric Davis <edavis@littlestreamsoftware.com>
Sat, 14 Nov 2009 19:41:02 +0000 (19:41 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Sat, 14 Nov 2009 19:41:02 +0000 (19:41 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3050 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application_controller.rb
test/integration/admin_test.rb

index 68377b6f7b82799d286f012d48f753a33eb0d2eb..53259554813b5c49c3a6646471b3bc2addc5aed8 100644 (file)
@@ -93,7 +93,13 @@ class ApplicationController < ActionController::Base
   
   def require_login
     if !User.current.logged?
-      redirect_to :controller => "account", :action => "login", :back_url => url_for(params)
+      # Extract only the basic url parameters on non-GET requests
+      if request.get?
+        url = url_for(params)
+      else
+        url = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id], :project_id => params[:project_id])
+      end
+      redirect_to :controller => "account", :action => "login", :back_url => url
       return false
     end
     true
index 66c6b21cd7329555b9ff2eb1a1705284d279108a..9ea9e9809651597e3e70cb00e820484ef294ad45 100644 (file)
@@ -40,4 +40,10 @@ class AdminTest < ActionController::IntegrationTest
     locked_user = User.try_to_login("psmith", "psmith09")
     assert_equal nil, locked_user
   end
+
+  test "Add a user as an anonymous user should fail" do
+    post '/users/add', :user => { :login => 'psmith', :firstname => 'Paul'}, :password => "psmith09", :password_confirmation => "psmith09"
+    assert_response :redirect
+    assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fusers%2Fnew"
+  end
 end