-
-
Save binarytemple/5b112a7cb0ba2ceca18b to your computer and use it in GitHub Desktop.
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
%% 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