Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save binarytemple/5b112a7cb0ba2ceca18b to your computer and use it in GitHub Desktop.
Save binarytemple/5b112a7cb0ba2ceca18b to your computer and use it in GitHub Desktop.
%% Old version. Boo!!
tenant_id(TokenItems) ->
{struct, AccessItems} = proplists:get_value(<<"access">>, TokenItems, []),
{struct, UserItems} = proplists:get_value(<<"user">>, AccessItems, []),
case proplists:get_value(<<"tenantId">>, UserItems) of
undefined ->
failed;
TenantId ->
{ok, TenantId}
end.
%% New version. It's so beautiful!
tenant_id({error, decode_failed}) ->
failed;
tenant_id(Token) ->
riak_cs_json:get(Token, [<<"access">>, <<"user">>, <<"tenantId">>]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment