On 06/03/2011 06:31 PM, mtaylor(a)redhat.com wrote:
From: Martyn Taylor<mtaylor(a)redhat.com>
---
src/app/controllers/application_controller.rb | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/app/controllers/application_controller.rb
b/src/app/controllers/application_controller.rb
index cb4a1d3..c9b2949 100644
--- a/src/app/controllers/application_controller.rb
+++ b/src/app/controllers/application_controller.rb
@@ -212,10 +212,15 @@ class ApplicationController< ActionController::Base
end
def require_user
- return if current_user
- store_location
- flash[:notice] = "You must be logged in to access this page"
- redirect_to login_url
+ respond_to do |format|
+ format.html do
+ return if current_user
+ store_location
+ flash[:notice] = "You must be logged in to access this page"
+ redirect_to login_url
+ end
+ format.xml { head :unauthorized }
+ end
end
def require_no_user
Hey Martyn,
Great idea. Unfortunately, this patch return 401 for all xml request --
even the authorized ones.
Thomas
--
No trees were killed to send this message, but a large number of
electrons were terribly inconvenienced.