From 6a5c9a59b3d79af19b468281943d26ed8333b6f9 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Fri, 24 Sep 2010 18:03:37 -0300 Subject: [PATCH] Do not redirect AJAX requests --- lib/authenticated_system.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/authenticated_system.rb b/lib/authenticated_system.rb index 161eaa7..04826ee 100644 --- a/lib/authenticated_system.rb +++ b/lib/authenticated_system.rb @@ -64,8 +64,12 @@ module AuthenticatedSystem def access_denied respond_to do |accepts| accepts.html do - store_location - redirect_to :controller => '/account', :action => 'login' + if request.xhr? + render :text => _('Access denied'), :status => 401 + else + store_location + redirect_to :controller => '/account', :action => 'login' + end end accepts.xml do headers["Status"] = "Unauthorized" -- libgit2 0.21.2