Sha256: 3d01e70389d9e71b15137284b7ad28ad3b41d964a71d1d000be6f4c5f4bd2395
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
require 'facemock' module Facemock module OAuth class Authentication < RackMiddleware class << self attr_accessor :path end DEFAULT_PATH = "/facemock/oauth" @path = DEFAULT_PATH def call(env) if env["PATH_INFO"] == Authentication.path && env["REQUEST_METHOD"] == "POST" raw_body = URI.unescape(env['rack.input'].gets) body = query_string_to_hash(raw_body) email = body["email"] password = body["pass"] user = Facemock::User.find_by_email(email) if user && user.password == password code = Facemock::AuthorizationCode.create!(user_id: user.id) location = location(env, CallbackHook.path, { code: code.string }) else location = location(env, "/facemock/sign_in") end code = 302 body = [] header = { "Content-Type" => "text/html;charset=utf-8", "Location" => location, "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 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
facemock-oauth-0.0.6 | lib/facemock/oauth/authentication.rb |
facemock-oauth-0.0.5 | lib/facemock/oauth/authentication.rb |