Permalink
Browse files

Fix symbole downcase issue

  • Loading branch information...
1 parent 2450e95 commit f549d2a10848b3e9f234ce7fa8c2c3afaa06857e @thibaudgg committed Jul 4, 2012
Showing with 10 additions and 10 deletions.
  1. +10 −10 lib/rack/private.rb
View
@@ -1,6 +1,6 @@
module Rack
class Private
-
+
def initialize(app, options = {}, &block)
@app = app
@options = options
@@ -12,13 +12,13 @@ def initialize(app, options = {}, &block)
instance_eval(&block) if block_given?
end
-
+
def call(env)
request = Rack::Request.new(env)
-
+
# Check code in session and return Rails call if is valid
return @app.call(env) if (already_auth?(request) || public_page?(request))
-
+
# If post method check :code_param value
if request.post? && code_valid?(request.params["private_code"])
request.session[:private_code] = request.params["private_code"]
@@ -28,28 +28,28 @@ def call(env)
render_private_form
end
end
-
+
private
# Render staging html file
def render_private_form
[200, {'Content-Type' => 'text/html'}, [
::File.open(html_template, 'rb').read
]]
end
-
+
def html_template
@options[:template_path] || ::File.expand_path('../private/index.html', __FILE__)
end
-
+
# Validate code
def code_valid?(code)
[@options[:code] || @options[:codes]].flatten.include?(code)
end
-
+
def already_auth?(request)
code_valid?(request.session[:private_code])
end
-
+
# Checks if the url matches one of our exception strings or regexs
def public_page?(request)
@exceptions.find {|exception| exception?(request, exception)}
@@ -66,7 +66,7 @@ def matches_path?(request, path)
def matches_method?(request, method)
return true if method.nil?
- request.request_method.downcase == method.values.first.downcase.to_s
+ request.request_method.to_s.downcase == method.values.first.to_s.downcase
end
def except(match, method = nil)

0 comments on commit f549d2a

Please sign in to comment.