Skip to content

Instantly share code, notes, and snippets.

@ouranos
Created May 25, 2015 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ouranos/ab87ef9fc9267d05b9f5 to your computer and use it in GitHub Desktop.
Save ouranos/ab87ef9fc9267d05b9f5 to your computer and use it in GitHub Desktop.
# config/application.rb
config.middleware.insert_after ActionDispatch::Flash, Warden::Manager do |manager|
manager.default_strategies :authentication_token
manager.failure_app = UnauthorizedController
end
# app/controllers/unauthorized_controller.rb
class UnauthorizedController < ActionController::Metal
def self.call(env)
@respond ||= action(:respond)
@respond.call(env)
end
def respond
self.response_body = "Unauthorized Action"
self.status = :unauthorized
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment