From e5821123698035f022c6a27ece411d91e3b33e8a Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 1 Sep 2010 05:29:28 +0800 Subject: [PATCH] set WWW-Authenticate header on http_auth if request is not xhr --- lib/devise/failure_app.rb | 2 +- test/failure_app_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/devise/failure_app.rb b/lib/devise/failure_app.rb index 46f8bcff..4705f108 100644 --- a/lib/devise/failure_app.rb +++ b/lib/devise/failure_app.rb @@ -33,7 +33,7 @@ module Devise def http_auth self.status = 401 - self.headers["WWW-Authenticate"] = %(Basic realm=#{Devise.http_authentication_realm.inspect}) + self.headers["WWW-Authenticate"] = %(Basic realm=#{Devise.http_authentication_realm.inspect}) unless request.xhr? self.content_type = request.format.to_s self.response_body = http_auth_body end diff --git a/test/failure_app_test.rb b/test/failure_app_test.rb index ef9fceaf..a614d8ed 100644 --- a/test/failure_app_test.rb +++ b/test/failure_app_test.rb @@ -99,7 +99,7 @@ class FailureTest < ActiveSupport::TestCase swap Devise, :http_authenticatable_on_xhr => true do call_failure('formats' => :html, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest') assert_equal 401, @response.first - assert_equal 'Basic realm="Application"', @response.second["WWW-Authenticate"] + assert_nil @response.second['WWW-Authenticate'] end end