Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Use config module for allowed_owner setting
COUCHDB-2585
  • Loading branch information
iilyak committed Feb 18, 2015
1 parent 9c867e8 commit 861fade15517e2edac4fc96ec3cc164083ca6ab7
Showing 2 changed files with 8 additions and 5 deletions.
@@ -250,10 +250,11 @@ to_non_neg_int(Value) ->
end.

allowed_owner(Req) ->
case application:get_env(global_changes, allowed_owner) of
case config:get("global_changes", "allowed_owner", undefined) of
undefined ->
chttpd:verify_is_server_admin(Req),
admin;
{ok, {M, F, A}} ->
SpecStr ->
{ok, {M, F, A}} = couch_util:parse_term(SpecStr),
M:F(Req, A)
end.
@@ -5,6 +5,8 @@

-export([allowed_owner/2]).

-define(t2l(V), lists:flatten(io_lib:format("~p", [V]))).

start() ->
Ctx = test_util:start_couch([chttpd]),
DbName = ?tempdb(),
@@ -24,13 +26,13 @@ setup(default) ->
get_host();
setup(A) ->
Host = setup(default),
ok = application:set_env(global_changes, allowed_owner,
{?MODULE, allowed_owner, A}),
ok = config:set("global_changes", "allowed_owner",
?t2l({?MODULE, allowed_owner, A}), false),
Host.

teardown(_) ->
delete_admin("admin"),
application:unset_env(global_changes, allowed_owner),
config:delete("global_changes", "allowed_owner", false),
ok.

allowed_owner(Req, "throw") ->

0 comments on commit 861fade

Please sign in to comment.