Skip to content

Instantly share code, notes, and snippets.

@spidergears
Last active December 22, 2015 01:29
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 spidergears/6396928 to your computer and use it in GitHub Desktop.
Save spidergears/6396928 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
protect_from_forgery
end
def protect_from_forgery(options = {})
self.request_forgery_protection_token ||= :authenticity_token
prepend_before_action :verify_authenticity_token, options
end
def verify_authenticity_token
unless verified_request?
logger.warn "Can't verify CSRF token authenticity" if logger
handle_unverified_request
end
end
def handle_unverified_request
reset_session
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment