Sha256: fdd42ebed0f208abc1fe04c84526d06eca5bc724eb194fa6a043925d01425e91

Contents?: true

Size: 984 Bytes

Versions: 4

Compression:

Stored size: 984 Bytes

Contents

# -*- coding: utf-8 -*-

module Facemock
  module OAuth
    class Login < RackMiddleware
      VIEW_DIRECTORY = File.expand_path("../../../../view", __FILE__)
      VIEW_FILE_NAME = "login.html"
      DEFAULT_PATH = "/facemock/sign_in"
      @path = DEFAULT_PATH

      def call(env)
        if env["PATH_INFO"] == Login.path
          code   = 200
          body   = [ Login.view ]
          header = { "Content-Type"           => "text/html;charset=utf-8",
                     "Content-Length"         => content_length(body).to_s,
                     "X-XSS-Protection"       => "1; mode=block",
                     "X-Content-Type-Options" => "nosniff",
                     "X-Frame-Options"        => "SAMEORIGIN" }
          [code, header, body]
        else
          super
        end
      end

      def self.view
        File.read(filepath)
      end

      private

      def self.filepath
        File.join(VIEW_DIRECTORY, VIEW_FILE_NAME)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facemock-oauth-0.0.4 lib/facemock/oauth/login.rb
facemock-oauth-0.0.3 lib/facemock/oauth/login.rb
facemock-oauth-0.0.2 lib/facemock/oauth/login.rb
facemock-oauth-0.0.1 lib/facemock/oauth/login.rb