Skip to content

Commit

Permalink
Added AccountUUID and UserUUID arguments to `sup crossbar_maintenance
Browse files Browse the repository at this point in the history
create_account`
  • Loading branch information
T0ha authored and noahmehl committed Apr 29, 2020
1 parent 074710f commit 274aa26
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions applications/crossbar/src/crossbar_maintenance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
,register_views/0
,flush/0
]).

-export([find_account_by_number/1]).
-export([find_account_by_name/1]).
-export([find_account_by_realm/1]).
-export([find_account_by_id/1]).
-export([enable_account/1, disable_account/1]).
-export([promote_account/1, demote_account/1]).
-export([allow_account_number_additions/1, disallow_account_number_additions/1]).
-export([create_account/4]).
-export([create_account/4, create_account/5, create_account/6]).
-export([create_account/1]).
-export([move_account/2]).
-export([descendants_count/0, descendants_count/1]).
Expand Down Expand Up @@ -382,19 +383,29 @@ demote_account(AccountId) ->
%% @end
%%------------------------------------------------------------------------------
-spec create_account(input_term(), input_term(), input_term(), input_term()) -> 'ok' | 'failed'.
create_account(AccountName, Realm, Username, Password)
create_account(AccountName, Realm, Username, Password) ->
create_account(AccountName, Realm, Username, Password, kz_datamgr:get_uuid()).

-spec create_account(input_term(), input_term(), input_term(), input_term(), input_term()) -> 'ok' | 'failed'.
create_account(AccountName, Realm, Username, Password, AccountId) ->
create_account(AccountName, Realm, Username, Password, AccountId, kz_datamgr:get_uuid()).

-spec create_account(input_term(), input_term(), input_term(), input_term(), input_term(), input_term()) -> 'ok' | 'failed'.
create_account(AccountName, Realm, Username, Password, AccountId, UserId)
when is_binary(AccountName),
is_binary(Realm),
is_binary(Username),
is_binary(Password) ->
Account = kz_json:set_values([{<<"_id">>, kz_datamgr:get_uuid()}
is_binary(Password),
is_binary(AccountId),
is_binary(UserId) ->
Account = kz_json:set_values([{<<"_id">>, AccountId}
,{<<"name">>, AccountName}
,{<<"realm">>, Realm}
]
,kzd_accounts:new()
),

User = kz_json:set_values([{<<"_id">>, kz_datamgr:get_uuid()}
User = kz_json:set_values([{<<"_id">>, UserId}
,{<<"username">>, Username}
,{<<"password">>, Password}
,{<<"first_name">>, <<"Account">>}
Expand All @@ -419,11 +430,13 @@ create_account(AccountName, Realm, Username, Password)
io:format("failed to create '~s': ~p~n", [AccountName, _R]),
'failed'
end;
create_account(AccountName, Realm, Username, Password) ->
create_account(AccountName, Realm, Username, Password, AccountId, UserId) ->
create_account(kz_term:to_binary(AccountName)
,kz_term:to_binary(Realm)
,kz_term:to_binary(Username)
,kz_term:to_binary(Password)
,kz_term:to_binary(AccountId)
,kz_term:to_binary(UserId)
).

-spec maybe_promote_account(cb_context:context()) -> {'ok', cb_context:context()}.
Expand Down

0 comments on commit 274aa26

Please sign in to comment.