Skip to content

Instantly share code, notes, and snippets.

@knzai
Created April 13, 2010 19:35
Show Gist options
  • Save knzai/364997 to your computer and use it in GitHub Desktop.
Save knzai/364997 to your computer and use it in GitHub Desktop.
def anon_access_denied
respond_to do |accepts|
accepts.html do
store_location
redirect_to login_path
end
accepts.xml do
headers["Status"] = "Unauthorized"
headers["WWW-Authenticate"] = %(Basic realm="Web Password")
render :text => "Could't authenticate you", :status => '401 Unauthorized'
end
accepts.js do
render(:update) { |page| page.redirect_to login_path }
end
end
end
def anon_access_denied
respond_to do |accepts|
accepts.html do
store_location
redirect_to login_path
end
accepts.xml do
headers["Status"] = "Unauthorized"
headers["WWW-Authenticate"] = %(Basic realm="Web Password")
render :text => "Could't authenticate you", :status => '401 Unauthorized'
end
accepts.js do
render(:update) { |page| page.redirect_to login_path }
end
accepts.any do
store_location
redirect_to login_path
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment