Skip to content

Commit

Permalink
KTEL-3: store password in context to send email if requested (#6682)
Browse files Browse the repository at this point in the history
  • Loading branch information
icehess authored and jamesaimonetti committed Dec 29, 2020
1 parent af35278 commit 1c1f74f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions applications/crossbar/src/modules_v2/cb_users_v2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,9 @@ maybe_send_email(Context) ->
send_email(Context) ->
lager:debug("trying to publish new user notification"),
Doc = cb_context:doc(Context),
ReqData = cb_context:req_data(Context),
Req = [{<<"Account-ID">>, cb_context:account_id(Context)}
,{<<"User-ID">>, kz_doc:id(Doc)}
,{<<"Password">>, kz_json:get_value(<<"password">>, ReqData)}
,{<<"Password">>, cb_context:fetch(Context, <<"req_password">>)}
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
],
kapps_notify_publisher:cast(Req, fun kapi_notifications:publish_new_user/1).
Expand Down Expand Up @@ -473,9 +472,11 @@ validate_patch(UserId, Context) ->
%% @end
%%------------------------------------------------------------------------------
-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context().
validate_request(UserId, Context) ->
ReqJObj = cb_context:req_data(Context),
AccountId = cb_context:account_id(Context),
validate_request(UserId, Context0) ->
ReqJObj = cb_context:req_data(Context0),
AccountId = cb_context:account_id(Context0),

Context = cb_context:store(Context0, <<"req_password">>, kz_json:get_value(<<"password">>, ReqJObj)),

case kzd_users:validate(AccountId, UserId, ReqJObj) of
{'true', UserJObj} when is_binary(UserId) ->
Expand Down

0 comments on commit 1c1f74f

Please sign in to comment.