From eed223d19d9c2fc595a783dbd0bae212c3d7d75b Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Thu, 6 Dec 2012 15:49:36 +0100 Subject: [PATCH] throw params in case or mismatch --- lib/travis/web/set_token.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/travis/web/set_token.rb b/lib/travis/web/set_token.rb index ce999553..d182045c 100644 --- a/lib/travis/web/set_token.rb +++ b/lib/travis/web/set_token.rb @@ -11,17 +11,19 @@ module Travis end def call(env) - return app.call(env) unless info = info_for(env) - Rack::Response.new(template % info).finish + set_info(env) || app.call(env) end - def info_for(env) + def set_info(env) return unless env['REQUEST_METHOD'] == 'POST' request = Rack::Request.new(env) token, user, storage = request.params.values_at('token', 'user', 'storage') if token =~ /\A[a-zA-Z\-_\d]+\Z/ storage = 'sessionStorage' if storage != 'localStorage' - [storage, token, user, request.fullpath] + info = [storage, token, user, request.fullpath] + Rack::Response.new(template % info).finish + else + [200, {'Content-Type' => 'text/plain'}, [request.params.inspect]] end end end