Created
April 13, 2009 22:43
-
-
Save sprite2005/94801 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
rescue_from ActionController::InvalidAuthenticityToken, :with => :bad_token | |
def bad_token | |
flash[:notice] = "Your session has expired." | |
respond_to do |accepts| | |
accepts.html do | |
store_location | |
redirect_to(:controller => '/sessions', :action => 'new') and return false | |
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 | |
store_location | |
render :update do |page| | |
page.redirect_to(:controller => '/sessions', :action => 'new') and return false | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment