diff options
author | Jan Lehnardt <jan@apache.org> | 2009-09-20 10:28:33 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2009-09-20 10:28:33 +0000 |
commit | 0dd76245aefd7a21537beb7ed1f70b9a06224dde (patch) | |
tree | 6c2454c8115f1e8f6e99441fafc718c792ca5b47 /src/couchdb/couch_httpd_oauth.erl | |
parent | 4ddb75549c6565b5a2ca9edec0d965bdf53eed11 (diff) |
remove some unneeded opening, closing and passing around of Db
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@817003 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_oauth.erl')
-rw-r--r-- | src/couchdb/couch_httpd_oauth.erl | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/couchdb/couch_httpd_oauth.erl b/src/couchdb/couch_httpd_oauth.erl index 3bfe52e7..c1a51413 100644 --- a/src/couchdb/couch_httpd_oauth.erl +++ b/src/couchdb/couch_httpd_oauth.erl @@ -31,18 +31,13 @@ oauth_authentication_handler(#httpd{mochi_req=MochiReq}=Req) -> % Look up the consumer key and get the roles to give the consumer set_user_ctx(Req, AccessToken) -> DbName = couch_config:get("couch_httpd_auth", "authentication_db"), - couch_httpd_auth:ensure_users_db_exists(?l2b(DbName)), - case couch_db:open(?l2b(DbName), [{user_ctx, #user_ctx{roles=[<<"_admin">>]}}]) of - {ok, Db} -> - Name = ?l2b(couch_config:get("oauth_token_users", AccessToken)), - case couch_httpd_auth:get_user(Db, Name) of - nil -> Req; - User -> - Roles = proplists:get_value(<<"roles">>, User, []), - Req#httpd{user_ctx=#user_ctx{name=Name, roles=Roles}} - end; - _Else-> - Req + {ok, _Db} = couch_httpd_auth:ensure_users_db_exists(?l2b(DbName)), + Name = ?l2b(couch_config:get("oauth_token_users", AccessToken)), + case couch_httpd_auth:get_user(Name) of + nil -> Req; + User -> + Roles = proplists:get_value(<<"roles">>, User, []), + Req#httpd{user_ctx=#user_ctx{name=Name, roles=Roles}} end. % OAuth request_token |