summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd_oauth.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/couchdb/couch_httpd_oauth.erl')
-rw-r--r--src/couchdb/couch_httpd_oauth.erl19
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