Sha256: 5236a3d7e86101c79b476ed3ec0a2f9e07e94abc9b55995aae848ece64a07531

Contents?: true

Size: 850 Bytes

Versions: 2

Compression:

Stored size: 850 Bytes

Contents

module Facemock
  module OAuth
    class LoginHook < RackMiddleware
      class << self
        attr_accessor :paths
      end

      DEFAULT_PATH = "/sign_in"
      @paths = [ DEFAULT_PATH ]

      def call(env)
        res = super
        if LoginHook.paths.include?(env["PATH_INFO"])
          code   = 302
          body   = []
          header = { "Content-Type"           => "text/html;charset=utf-8",
                     "Location"               => location(env, "/facemock/sign_in"),
                     "Content-Length"         => content_length(body).to_s,
                     "X-XSS-Protection"       => "1; mode=block",
                     "X-Content-Type-Options" => "nosniff",
                     "X-Frame-Options"        => "SAMEORIGIN" }
          res = [ code, header, body ]
        end
        res
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facemock-oauth-0.0.6 lib/facemock/oauth/login_hook.rb
facemock-oauth-0.0.5 lib/facemock/oauth/login_hook.rb