Skip to content

Commit

Permalink
Merge pull request 2600hz#1766 from 2600hz/knm-log
Browse files Browse the repository at this point in the history
knm-log: mark KNM actions that bypassed auth
  • Loading branch information
lazedo committed Apr 10, 2016
2 parents 5adb4ab + 62d53f3 commit 3cf2e09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion core/kazoo_number_manager/src/knm_number_states.erl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ authorize(Number) ->
).
-endif.

authorize(Number, ?KNM_DEFAULT_AUTH_BY) -> Number;
authorize(Number, ?KNM_DEFAULT_AUTH_BY) ->
lager:info("bypassing auth"),
Number;
authorize(Number, AuthBy) ->
AssignTo = knm_phone_number:assign_to(knm_number:phone_number(Number)),
case ?ACCT_HIERARCHY(AuthBy, AssignTo, 'true') of
Expand Down
12 changes: 8 additions & 4 deletions core/kazoo_number_manager/src/knm_phone_number.erl
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ authorize_release(_PhoneNumber, _AuthBy) ->
knm_errors:unauthorized().
-else.
authorize_release(PhoneNumber, ?KNM_DEFAULT_AUTH_BY) ->
lager:info("bypassing auth"),
authorized_release(PhoneNumber);
authorize_release(PhoneNumber, AuthBy) ->
AssignedTo = assigned_to(PhoneNumber),
Expand Down Expand Up @@ -640,9 +641,10 @@ list_attachments(PhoneNumber, AuthBy) ->
%%--------------------------------------------------------------------
-spec set_options(knm_phone_number(), knm_number_options:options()) -> knm_phone_number().
set_options(Number, Options) when is_list(Options) ->
Updates = [{fun set_dry_run/2, knm_number_options:dry_run(Options, 'false')}
,{fun set_auth_by/2, knm_number_options:auth_by(Options, ?KNM_DEFAULT_AUTH_BY)}
,{fun set_assign_to/2, knm_number_options:assign_to(Options)}
Updates = [{fun set_assign_to/2, knm_number_options:assign_to(Options)}
%% See knm_number_options:default/0 for these 2.
,{fun set_dry_run/2, knm_number_options:dry_run(Options, 'false')}
,{fun set_auth_by/2, knm_number_options:auth_by(Options, ?KNM_DEFAULT_AUTH_BY)}
],
{'ok', PhoneNumber} = setters(Number, Updates),
PhoneNumber.
Expand All @@ -662,7 +664,9 @@ is_authorized(#knm_phone_number{assigned_to=AssignedTo
(AssignedTo =:= ?RESELLER_ACCOUNT_ID orelse AssignedTo =:= ?MASTER_ACCOUNT_ID)
andalso (AuthBy =:= ?RESELLER_ACCOUNT_ID orelse AuthBy =:= ?MASTER_ACCOUNT_ID).
-else.
is_authorized(#knm_phone_number{auth_by= ?KNM_DEFAULT_AUTH_BY}) -> 'true';
is_authorized(#knm_phone_number{auth_by= ?KNM_DEFAULT_AUTH_BY}) ->
lager:info("bypassing auth"),
'true';
is_authorized(#knm_phone_number{assigned_to=AssignedTo
,auth_by=AuthBy
}) ->
Expand Down

0 comments on commit 3cf2e09

Please sign in to comment.