Skip to content

Instantly share code, notes, and snippets.

@mmzyk
Created July 9, 2015 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmzyk/0fc61cbf621d62469624 to your computer and use it in GitHub Desktop.
Save mmzyk/0fc61cbf621d62469624 to your computer and use it in GitHub Desktop.
%% Tells whether this user is the superuser.
is_superuser(Req) ->
UserName = list_to_binary(wrq:get_req_header("x-ops-userid", Req)),
is_superuser(UserName);
is_superuser(UserName) ->
Superusers = envy:get(oc_chef_wm, superusers, [], list),
lists:member(UserName, Superusers).
Lines 5 to 7 is the existing function. I want to add lines 2 to 4. How can I make it guard so if it's a webmachine request object, it uses the first fun head and if not otherwise uses the 2nd?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment