changes get user id to get party id instead (#37)

This commit is contained in:
Артем 2023-08-25 10:22:14 +03:00 committed by GitHub
parent d9db173e23
commit d5ed8b20f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 15 deletions

View File

@ -23,8 +23,7 @@
) -> {ok, capi_handler:request_state()} | {error, noimpl}.
prepare('CreateCustomer' = OperationID, Req, Context) ->
CustomerParams = maps:get('CustomerParams', Req),
UserID = capi_handler_utils:get_user_id(Context),
PartyID = maps:get(<<"partyID">>, CustomerParams, UserID),
PartyID = maps:get(<<"partyID">>, CustomerParams, capi_handler_utils:get_party_id(Context)),
ShopID = maps:get(<<"shopID">>, CustomerParams),
Authorize = fun() ->
Prototypes = [{operation, #{id => OperationID, party => PartyID, shop => ShopID}}],
@ -305,7 +304,7 @@ encode_customer_metadata(Meta) ->
generate_binding_ids(OperationID, CustomerBindingParams, Context = #{woody_context := WoodyContext}) ->
ExternalID = maps:get(<<"externalID">>, CustomerBindingParams, undefined),
UserID = capi_handler_utils:get_user_id(Context),
PartyID = capi_handler_utils:get_party_id(Context),
PaymentResource = maps:get(<<"paymentResource">>, CustomerBindingParams),
PaymentToolToken = maps:get(<<"paymentToolToken">>, PaymentResource),
@ -328,12 +327,12 @@ generate_binding_ids(OperationID, CustomerBindingParams, Context = #{woody_conte
OperationIDBin = erlang:atom_to_binary(OperationID),
CustomerBindingID = capi_bender:gen_snowflake(
{<<OperationIDBin/binary, "+CustomerBindingID">>, UserID, ExternalID},
{<<OperationIDBin/binary, "+CustomerBindingID">>, PartyID, ExternalID},
Identity,
WoodyContext
),
RecPaymentToolID = capi_bender:gen_snowflake(
{<<OperationIDBin/binary, "+RecPaymentToolID">>, UserID, ExternalID},
{<<OperationIDBin/binary, "+RecPaymentToolID">>, PartyID, ExternalID},
Identity,
WoodyContext
),

View File

@ -17,8 +17,7 @@
) -> {ok, capi_handler:request_state()} | {error, noimpl}.
prepare('CreateInvoiceTemplate' = OperationID, Req, Context) ->
InvoiceTemplateParams = maps:get('InvoiceTemplateCreateParams', Req),
UserID = capi_handler_utils:get_user_id(Context),
PartyID = maps:get(<<"partyID">>, InvoiceTemplateParams, UserID),
PartyID = maps:get(<<"partyID">>, InvoiceTemplateParams, capi_handler_utils:get_party_id(Context)),
Authorize = fun() ->
ShopID = maps:get(<<"shopID">>, InvoiceTemplateParams),
Prototypes = [{operation, #{party => PartyID, shop => ShopID, id => OperationID}}],

View File

@ -17,10 +17,7 @@
) -> {ok, capi_handler:request_state()} | {error, noimpl}.
prepare('CreateInvoice' = OperationID, Req, Context) ->
InvoiceParams = maps:get('InvoiceParams', Req),
UserID = capi_handler_utils:get_user_id(Context),
%% Now hellgate checks user's possibility use party.
%% After integration with bouncer, we have to remove validation in hellgate.
PartyID = maps:get(<<"partyID">>, InvoiceParams, UserID),
PartyID = maps:get(<<"partyID">>, InvoiceParams, capi_handler_utils:get_party_id(Context)),
Authorize = fun() ->
ShopID = maps:get(<<"shopID">>, InvoiceParams),
Prototypes = [

View File

@ -46,8 +46,7 @@ prepare(OperationID = 'GetPayout', Req, Context) ->
{ok, #{authorize => Authorize, process => Process}};
prepare(OperationID = 'CreatePayout', Req, Context) ->
PayoutParams = maps:get('PayoutParams', Req),
UserID = capi_handler_utils:get_user_id(Context),
PartyID = maps:get(<<"partyID">>, PayoutParams, UserID),
PartyID = maps:get(<<"partyID">>, PayoutParams, capi_handler_utils:get_party_id(Context)),
OperationContext = #{
id => OperationID,
party => PartyID,

View File

@ -16,8 +16,7 @@
) -> {ok, capi_handler:request_state()} | {error, noimpl}.
prepare('CreateWebhook' = OperationID, Req, Context) ->
Params = maps:get('Webhook', Req),
UserID = capi_handler_utils:get_user_id(Context),
PartyID = maps:get(<<"partyID">>, Params, UserID),
PartyID = maps:get(<<"partyID">>, Params, capi_handler_utils:get_party_id(Context)),
Authorize = fun() ->
Prototypes = [{operation, #{party => PartyID, id => OperationID}}],
Resolution = capi_auth:authorize_operation(Prototypes, Context),