summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd_auth.erl
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@apache.org>2010-09-30 12:03:15 +0000
committerFilipe David Borba Manana <fdmanana@apache.org>2010-09-30 12:03:15 +0000
commit6ae13b5f8b827bc87a8cf3306c3caa1b97e49df3 (patch)
tree9662164348a314705094f5f52456ab7bfe330df9 /src/couchdb/couch_httpd_auth.erl
parent1c0a6e9c637fcfec2990c6318b3c69e4c7591d76 (diff)
Removing ?getv macros.
With OTP releases up to R13B03 it's not possible to define a 2 macro functions with the same name and different arities. (Only allowed in R13B04 and R14). git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1003025 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_auth.erl')
-rw-r--r--src/couchdb/couch_httpd_auth.erl26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl
index b16a439e..f76898e1 100644
--- a/src/couchdb/couch_httpd_auth.erl
+++ b/src/couchdb/couch_httpd_auth.erl
@@ -69,14 +69,14 @@ default_authentication_handler(Req) ->
nil ->
throw({unauthorized, <<"Name or password is incorrect.">>});
UserProps ->
- UserSalt = ?getv(<<"salt">>, UserProps, <<>>),
+ UserSalt = couch_util:get_value(<<"salt">>, UserProps, <<>>),
PasswordHash = hash_password(?l2b(Pass), UserSalt),
- ExpectedHash = ?getv(<<"password_sha">>, UserProps, nil),
+ ExpectedHash = couch_util:get_value(<<"password_sha">>, UserProps, nil),
case couch_util:verify(ExpectedHash, PasswordHash) of
true ->
Req#httpd{user_ctx=#user_ctx{
name=?l2b(User),
- roles=?getv(<<"roles">>, UserProps, [])
+ roles=couch_util:get_value(<<"roles">>, UserProps, [])
}};
_Else ->
throw({unauthorized, <<"Name or password is incorrect.">>})
@@ -180,7 +180,7 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
case couch_auth_cache:get_user_creds(User) of
nil -> Req;
UserProps ->
- UserSalt = ?getv(<<"salt">>, UserProps, <<"">>),
+ UserSalt = couch_util:get_value(<<"salt">>, UserProps, <<"">>),
FullSecret = <<Secret/binary, UserSalt/binary>>,
ExpectedHash = crypto:sha_mac(FullSecret, User ++ ":" ++ TimeStr),
Hash = ?l2b(string:join(HashParts, ":")),
@@ -194,7 +194,7 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req) ->
?LOG_DEBUG("Successful cookie auth as: ~p", [User]),
Req#httpd{user_ctx=#user_ctx{
name=?l2b(User),
- roles=?getv(<<"roles">>, UserProps, [])
+ roles=couch_util:get_value(<<"roles">>, UserProps, [])
}, auth={FullSecret, TimeLeft < Timeout*0.9}};
_Else ->
Req
@@ -215,9 +215,9 @@ cookie_auth_header(#httpd{user_ctx=#user_ctx{name=User}, auth={Secret, true}}, H
% or logout handler.
% The login and logout handlers need to set the AuthSession cookie
% themselves.
- CookieHeader = ?getv("Set-Cookie", Headers, ""),
+ CookieHeader = couch_util:get_value("Set-Cookie", Headers, ""),
Cookies = mochiweb_cookies:parse_cookie(CookieHeader),
- AuthSession = ?getv("AuthSession", Cookies),
+ AuthSession = couch_util:get_value("AuthSession", Cookies),
if AuthSession == undefined ->
TimeStamp = make_cookie_time(),
[cookie_auth_cookie(?b2l(User), Secret, TimeStamp)];
@@ -261,16 +261,16 @@ handle_session_req(#httpd{method='POST', mochi_req=MochiReq}=Req) ->
_ ->
[]
end,
- UserName = ?l2b(?getv("name", Form, "")),
- Password = ?l2b(?getv("password", Form, "")),
+ UserName = ?l2b(couch_util:get_value("name", Form, "")),
+ Password = ?l2b(couch_util:get_value("password", Form, "")),
?LOG_DEBUG("Attempt Login: ~s",[UserName]),
User = case couch_auth_cache:get_user_creds(UserName) of
nil -> [];
Result -> Result
end,
- UserSalt = ?getv(<<"salt">>, User, <<>>),
+ UserSalt = couch_util:get_value(<<"salt">>, User, <<>>),
PasswordHash = hash_password(Password, UserSalt),
- ExpectedHash = ?getv(<<"password_sha">>, User, nil),
+ ExpectedHash = couch_util:get_value(<<"password_sha">>, User, nil),
case couch_util:verify(ExpectedHash, PasswordHash) of
true ->
% setup the session cookie
@@ -287,8 +287,8 @@ handle_session_req(#httpd{method='POST', mochi_req=MochiReq}=Req) ->
send_json(Req#httpd{req_body=ReqBody}, Code, Headers,
{[
{ok, true},
- {name, ?getv(<<"name">>, User, null)},
- {roles, ?getv(<<"roles">>, User, [])}
+ {name, couch_util:get_value(<<"name">>, User, null)},
+ {roles, couch_util:get_value(<<"roles">>, User, [])}
]});
_Else ->
% clear the session