提交 8c97f49f 编写于 作者: E Emilio Tagua 提交者: Santiago Pastorino

Refactor decode_credentials to avoid inject and use map instead.

Signed-off-by: NSantiago Pastorino <santiago@wyeworks.com>
上级 6d8a6700
......@@ -30,7 +30,7 @@ module HttpAuthentication
#
#
# === Advanced \Basic example
#
#
# Here is a more advanced \Basic example where only Atom feeds and the XML API is protected by HTTP authentication,
# the regular HTML interface is protected by a session approach:
#
......@@ -98,7 +98,7 @@ module HttpAuthentication
# end
#
# === Notes
#
#
# The +authenticate_or_request_with_http_digest+ block must return the user's password
# or the ha1 digest hash so the framework can appropriately hash to check the user's
# credentials. Returning +nil+ will cause authentication to fail.
......@@ -222,11 +222,10 @@ def decode_credentials_header(request)
end
def decode_credentials(header)
header.to_s.gsub(/^Digest\s+/,'').split(',').inject({}) do |hash, pair|
Hash[header.to_s.gsub(/^Digest\s+/,'').split(',').map do |pair|
key, value = pair.split('=', 2)
hash[key.strip.to_sym] = value.to_s.gsub(/^"|"$/,'').gsub(/'/, '')
hash
end
[key.strip.to_sym, value.to_s.gsub(/^"|"$/,'').gsub(/'/, '')]
end]
end
def authentication_header(controller, realm)
......
......@@ -189,7 +189,7 @@ def _instance_variables
end
def _assigns
_instance_variables.map { |var| [ var[1..-1].to_sym, instance_variable_get(var)] }
_instance_variables.map { |var| [var[1..-1].to_sym, instance_variable_get(var)] }
end
def _routes
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册