lib/roda/plugins/route_csrf.rb
def check_csrf!(opts=OPTS, &block)
          if msg = csrf_invalid_message(opts)
            if block
              @_request.on(&block)
            end
            
            case failure_action = opts.fetch(:csrf_failure, csrf_options[:csrf_failure])
            when :raise
              raise InvalidToken, msg
            when :empty_403
              throw :halt, [403, {'Content-Type'=>'text/html', 'Content-Length'=>'0'}, []]
            when :clear_session
              session.clear
            when :csrf_failure_method
              @_request.on{_roda_route_csrf_failure(@_request)}
            when Proc
              RodaPlugins.warn "Passing a Proc as the :csrf_failure option value to check_csrf! is deprecated"
              @_request.on{instance_exec(@_request, &failure_action)} # Deprecated
            else
              raise RodaError, "Unsupported :csrf_failure option: #{failure_action.inspect}"
            end
          end
        end
# Check that the submitted CSRF token is valid, if the request requires a CSRF token.
# If the CSRF token is valid or the request does not require a CSRF token, return nil.
# Otherwise, if a block is given, treat it as a routing block and yield to it, and
# if a block is not given, use the :csrf_failure option to determine how to handle it.
Check that the submitted CSRF token is valid, if the request requires a CSRF token.
If the CSRF token is valid or the request does not require a CSRF token, return nil.
Otherwise, if a block is given, treat it as a routing block and yield to it, and
if a block is not given, use the :csrf_failure option to determine how to handle it.
Check that the submitted CSRF token is valid if the request requires a CSRF token . If the CSRF token is valid or the request does not require a CSRF token return nil . Otherwise if a block is given treat it as a routing block and yield to it and if a block is not given use the : csrf_failure option to determine how to handle it .
def check_csrf!(opts=OPTS, &block)
          if msg = csrf_invalid_message(opts)
            if block
              @_request.on(&block)
            end
            case failure_action = opts.fetch(:csrf_failure, csrf_options[:csrf_failure])
            when :raise
              raise InvalidToken, msg
            when :empty_403
              throw :halt, [403, {'Content-Type'=>'text/html', 'Content-Length'=>'0'}, []]
            when :clear_session
              session.clear
            when :csrf_failure_method
              @_request.on{_roda_route_csrf_failure(@_request)}
            when Proc
              RodaPlugins.warn "Passing a Proc as the :csrf_failure option value to check_csrf! is deprecated"
              @_request.on{instance_exec(@_request, &failure_action)} 
            else
              raise RodaError, "Unsupported :csrf_failure option: #{failure_action.inspect}"
            end
          end
        end
def check_csrf! ( opts = OPTS , & block ) if msg = csrf_invalid_message ( opts ) if block @_request . on ( & block ) end case failure_action = opts . fetch ( :csrf_failure , csrf_options [ :csrf_failure ] ) when :raise raise InvalidToken , msg when :empty_403 throw :halt , [ 403 , { 'Content-Type' => 'text/html' , 'Content-Length' => '0' } , [ ] ] when :clear_session session . clear when :csrf_failure_method @_request . on { _roda_route_csrf_failure ( @_request ) } when Proc RodaPlugins . warn "Passing a Proc as the :csrf_failure option value to check_csrf! is deprecated" @_request . on { instance_exec ( @_request , & failure_action ) } else raise RodaError , "Unsupported :csrf_failure option: #{failure_action.inspect}" end end end
Check that the submitted CSRF token is valid, if the request requires a CSRF token.
Check that the submitted CSRF token is valid if the request requires a CSRF token .
# Deprecated
opts
block