This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check_is_admin(#db{user_ctx=#user_ctx{name=Name,roles=Roles}}=Db) -> | |
{Admins} = get_admins(Db), | |
AdminRoles = [<<"_admin">> | couch_util:get_value(<<"roles">>, Admins, [])], | |
AdminNames = couch_util:get_value(<<"names">>, Admins,[]), | |
case AdminRoles -- Roles of | |
AdminRoles -> % same list, not an admin role | |
case AdminNames -- [Name] of | |
AdminNames -> % same names, not an admin | |
throw({unauthorized, <<"You are not a db or server admin.">>}); | |
_ -> | |
ok | |
end; | |
_ -> | |
ok | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment