Sha256: 08de11e208f51cf241d667dade0dc6c3a564e0d17bf0807634c0f6f7ef6af986

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

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

module Facemock
  module OAuth
    class Login < RackMiddleware
      class << self
        attr_accessor :path
      end

      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

2 entries across 2 versions & 1 rubygems

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