Skip to content

Commit

Permalink
KAZOO-3766: cleanup authenticate/1 and fix arg order
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaimonetti committed May 21, 2015
1 parent 2bd8501 commit c607ab7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions applications/crossbar/src/modules/cb_user_auth.erl
@@ -1,5 +1,5 @@
%%%-------------------------------------------------------------------
%%% @copyright (C) 2011-2014, 2600Hz
%%% @copyright (C) 2011-2015, 2600Hz
%%% @doc
%%% User auth module
%%% @end
Expand Down Expand Up @@ -90,7 +90,7 @@ authorize_nouns(_) -> 'false'.
authenticate(Context) ->
authenticate_nouns(cb_context:req_nouns(Context)).

authenticate_nouns([{<<"user_auth">>, _}]) -> 'true';
authenticate_nouns([{<<"user_auth">>, []}]) -> 'true';
authenticate_nouns([{<<"user_auth">>, [?RECOVERY]}]) -> 'true';
authenticate_nouns(_Nouns) -> 'false'.

Expand Down Expand Up @@ -155,18 +155,17 @@ maybe_get_auth_token(Context, Token) ->
%% @end
%%--------------------------------------------------------------------
-spec create_auth_resp(cb_context:context(), ne_binary(), ne_binary(), ne_binary()) -> cb_context:context().
create_auth_resp(Context, _Token, _AccountId, 'undefined') ->
cb_context:add_system_error('forbidden', Context);
create_auth_resp(Context, Token, AccountId, AccountId) ->
lager:debug("account ~s is same as auth account", [AccountId]),
RespData = cb_context:resp_data(Context),
crossbar_util:response(
crossbar_util:response_auth(RespData)
,cb_context:set_auth_token(Context, Token)
);
create_auth_resp(Context, _Token, _AccountId, _AuthAccountId) ->
crossbar_util:response_auth(RespData)
,cb_context:set_auth_token(Context, Token)
);
create_auth_resp(Context, _AccountId, _Token, _AuthAccountId) ->
lager:debug("forbidding token for account ~s and auth account ~s", [_AccountId, _AuthAccountId]),
cb_context:add_system_error('forbidden', Context).


%%--------------------------------------------------------------------
%% @private
%% @doc
Expand Down

0 comments on commit c607ab7

Please sign in to comment.