-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: handle subaccount case in gaec #3876
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,8 +45,9 @@ const responseBuilder = async (metadata, message, { Config }, payload) => { | |
let { customerId, loginCustomerId } = Config; | ||
const { configData } = Config; | ||
|
||
let configDetails = {}; | ||
if (isDefinedAndNotNull(configData)) { | ||
const configDetails = JSON.parse(configData); | ||
configDetails = JSON.parse(configData); | ||
customerId = configDetails.customerId; | ||
if (isDefined(configDetails.loginCustomerId)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this code piece is not needed |
||
loginCustomerId = configDetails.loginCustomerId; | ||
|
@@ -70,6 +71,7 @@ const responseBuilder = async (metadata, message, { Config }, payload) => { | |
'developer-token': getValueFromMessage(metadata, 'secret.developer_token'), | ||
}; | ||
response.params = { event, customerId: filteredCustomerId }; | ||
|
||
if (subAccount) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here add additional condition to execute this logic only if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
if (!loginCustomerId) { | ||
throw new ConfigurationError(`loginCustomerId is required as subAccount is true.`); | ||
|
@@ -84,7 +86,9 @@ const responseBuilder = async (metadata, message, { Config }, payload) => { | |
response.headers['login-customer-id'] = filteredLoginCustomerId; | ||
} | ||
|
||
if (loginCustomerId) { | ||
// isDefined and non empty loginCustomerId | ||
if (isDefined(configDetails.loginCustomerId) && configDetails.loginCustomerId) { | ||
loginCustomerId = configDetails.loginCustomerId; | ||
const filteredLoginCustomerId = removeHyphens(loginCustomerId); | ||
response.headers['login-customer-id'] = filteredLoginCustomerId; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why
let
--> you are not updating the variable twiceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
earlier was reassigning it so used let, now using ternary condition and const