couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [6/9] couch-mrview commit: updated refs/heads/master to 065dc26
Date Fri, 30 Jan 2015 18:10:59 GMT
Move some logic into is_public_fields_configured function

COUCHDB-1145


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/ca9ed2f9
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/ca9ed2f9
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/ca9ed2f9

Branch: refs/heads/master
Commit: ca9ed2f99fad128ad6ceec23322477243d14f3c9
Parents: 6caa60f
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Wed Dec 31 10:42:02 2014 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Wed Dec 31 10:47:18 2014 -0800

----------------------------------------------------------------------
 src/couch_mrview_http.erl | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/ca9ed2f9/src/couch_mrview_http.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_http.erl b/src/couch_mrview_http.erl
index 9df1bdd..db7d2f4 100644
--- a/src/couch_mrview_http.erl
+++ b/src/couch_mrview_http.erl
@@ -186,29 +186,36 @@ all_docs_req(Req, Db, Keys, NS) ->
         ok ->
             do_all_docs_req(Req, Db, Keys, NS);
         _ ->
-            DbName = ?b2l(Db#db.name),
-            case config:get("couch_httpd_auth",
-                                  "authentication_db",
-                                  "_users") of
-            DbName ->
-                UsersDbPublic = config:get("couch_httpd_auth", "users_db_public", "false"),
-                PublicFields = config:get("couch_httpd_auth", "public_fields"),
-                case {UsersDbPublic, PublicFields} of
-                {"true", PublicFields} when PublicFields =/= undefined ->
+            case is_public_fields_configured(Db) of
+                true ->
                     do_all_docs_req(Req, Db, Keys, NS);
-                {_, _} ->
+                false ->
                     throw({forbidden, <<"Only admins can access _all_docs",
                                         " of system databases.">>})
-                end;
-            _ ->
-                throw({forbidden, <<"Only admins can access _all_docs",
-                                    " of system databases.">>})
             end
         end;
     false ->
         do_all_docs_req(Req, Db, Keys, NS)
     end.
 
+is_public_fields_configured(Db) ->
+    DbName = ?b2l(Db#db.name),
+    case config:get("couch_httpd_auth",
+                          "authentication_db",
+                          "_users") of
+    DbName ->
+        UsersDbPublic = config:get("couch_httpd_auth", "users_db_public", "false"),
+        PublicFields = config:get("couch_httpd_auth", "public_fields"),
+        case {UsersDbPublic, PublicFields} of
+        {"true", PublicFields} when PublicFields =/= undefined ->
+            true;
+        {_, _} ->
+            false
+        end;
+    _ ->
+        false
+    end.
+
 do_all_docs_req(Req, Db, Keys, NS) ->
     Args0 = parse_params(Req, Keys),
     Args1 = set_namespace(NS, Args0),


Mime
View raw message