lib/warden/jwt_auth/hooks.rb in warden-jwt_auth-0.2.0 vs lib/warden/jwt_auth/hooks.rb in warden-jwt_auth-0.2.1

- old
+ new

@@ -27,23 +27,25 @@ token = UserEncoder.new.call(user, scope) env[PREPARED_TOKEN_ENV_KEY] = token end def token_should_be_added?(scope, env) - jwt_scope?(scope) && request_matches?(env) + path_info = EnvHelper.path_info(env) + method = EnvHelper.request_method(env) + jwt_scope?(scope) && request_matches?(path_info, method) end def jwt_scope?(scope) jwt_scopes = mappings.keys jwt_scopes.include?(scope) end - # :reek:FeatureEnvy - def request_matches?(env) + # :reek:ControlParameter + def request_matches?(path_info, method) dispatch_requests.each do |tuple| - method, path = tuple - return true if env['PATH_INFO'].match(path) && - env['REQUEST_METHOD'] == method + dispatch_method, dispatch_path = tuple + return true if path_info.match(dispatch_path) && + method == dispatch_method end false end end end