def call(env)
      conf = configuration(env)
      if login_required?(env)
        if interactive?(env)
          ::Warden::Strategies[conf.ui_mode].new(env).on_ui_failure.finish
        else
          headers = {}
          headers["WWW-Authenticate"] =
            conf.api_modes.collect { |mode_key|
            ::Warden::Strategies[mode_key].new(env).challenge
          }.join("\n")
          headers["Content-Type"] = "text/plain"
          [401, headers, ["Authentication required"]]
        end
      else
        log_authorization_failure(env)
        msg = "#{user(env).username} may not use this page."
        Rack::Response.
          new("<html><head><title>Authorization denied</title></head><body>#{msg}</body></html>",
              403,
              "Content-Type" => "text/html").finish
      end
    end
def call(env)
      conf = configuration(env)
      if login_required?(env)
        if interactive?(env)
          ::Warden::Strategies[conf.ui_mode].new(env).on_ui_failure.finish
        else
          headers = {}
          headers["WWW-Authenticate"] =
            conf.api_modes.collect { |mode_key|
            ::Warden::Strategies[mode_key].new(env).challenge
          }.join("\n")
          headers["Content-Type"] = "text/plain"
          [401, headers, ["Authentication required"]]
        end
      else
        log_authorization_failure(env)
        msg = "#{user(env).username} may not use this page."
        Rack::Response.
          new("<html><head><title>Authorization denied</title></head><body>#{msg}</body></html>",
              403,
              "Content-Type" => "text/html").finish
      end
    end
Receives the rack environment in case of a failure and renders a
 response based on the interactiveness of the request and the
 nature of the configured modes.

 @param [Hash] env a rack environment

 @return [Array] a rack response