couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From klaus_trai...@apache.org
Subject couchdb-peruser git commit: Use predefined `ADMIN_CTX` macro
Date Wed, 12 Aug 2015 09:36:54 GMT
Repository: couchdb-peruser
Updated Branches:
  refs/heads/master bb95f4a28 -> c3a59aab0


Use predefined `ADMIN_CTX` macro

See `couch/include/couch_db.hrl`.


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

Branch: refs/heads/master
Commit: c3a59aab0beabf86b496b7d568ef72b7b9136909
Parents: bb95f4a
Author: Klaus Trainer <klaus_trainer@posteo.de>
Authored: Wed Aug 12 11:34:55 2015 +0200
Committer: Klaus Trainer <klaus_trainer@posteo.de>
Committed: Wed Aug 12 11:34:59 2015 +0200

----------------------------------------------------------------------
 src/couchdb_peruser.erl | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-peruser/blob/c3a59aab/src/couchdb_peruser.erl
----------------------------------------------------------------------
diff --git a/src/couchdb_peruser.erl b/src/couchdb_peruser.erl
index 34b0027..2bc2f6b 100644
--- a/src/couchdb_peruser.erl
+++ b/src/couchdb_peruser.erl
@@ -62,11 +62,8 @@ handle_config_change(_Section, _Key, _Value, _Persist, Server) ->
 handle_config_terminate(_Self, Reason, _Server) ->
     {stop, Reason}.
 
-admin_ctx() ->
-    {user_ctx, #user_ctx{roles=[<<"_admin">>]}}.
-
 init_changes_handler(State) ->
-    {ok, Db} = couch_db:open_int(State#state.db_name, [admin_ctx(), sys_db]),
+    {ok, Db} = couch_db:open_int(State#state.db_name, [?ADMIN_CTX, sys_db]),
     FunAcc = {fun ?MODULE:changes_handler/3, State},
     (couch_changes:handle_db_changes(
          #changes_args{feed="continuous", timeout=infinity},
@@ -105,7 +102,7 @@ terminate(_Reason, _State) ->
 delete_user_db(User) ->
     UserDb = user_db_name(User),
     try
-        fabric_db_delete:go(UserDb, [admin_ctx()])
+        fabric_db_delete:go(UserDb, [?ADMIN_CTX])
     catch error:database_does_not_exist ->
         ok
     end,
@@ -116,7 +113,7 @@ ensure_user_db(User) ->
     try
         fabric_db_info:go(UserDb)
     catch error:database_does_not_exist ->
-        fabric_db_create:go(UserDb, [admin_ctx()])
+        fabric_db_create:go(UserDb, [?ADMIN_CTX])
     end,
     UserDb.
 
@@ -137,7 +134,7 @@ add_user(User, Prop, {Modified, SecProps}) ->
     end.
 
 ensure_security(User, UserDb) ->
-    {ok, Shards} = fabric_db_meta:get_all_security(UserDb, [admin_ctx()]),
+    {ok, Shards} = fabric_db_meta:get_all_security(UserDb, [?ADMIN_CTX]),
     {_ShardInfo, {SecProps}} = hd(Shards),
     % assert that shards have the same security object
     true = lists:all(fun({_, {SecProps1}}) ->
@@ -150,7 +147,7 @@ ensure_security(User, UserDb) ->
     {false, _} ->
         ok;
     {true, SecProps1} ->
-        fabric_db_meta:set_security(UserDb, {SecProps1}, [admin_ctx()])
+        fabric_db_meta:set_security(UserDb, {SecProps1}, [?ADMIN_CTX])
     end.
 
 user_db_name(User) ->


Mime
View raw message