Skip to content

Commit 9767428

Browse files
author
Vikas Agarwal
committed
git#651-Return BA status in the GET billing account endpoint
— Allowing non m2m users to call the GET billing account details endpoint with sanitized fields
1 parent b230f81 commit 9767428

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/permissions/constants.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@ export const PERMISSION = { // eslint-disable-line import/prefer-default-export
293293
group: 'Project Billing Accounts',
294294
description: 'Who can view the details of the Billing Account attached to the project',
295295
},
296+
projectRoles: [
297+
...PROJECT_ROLES_MANAGEMENT,
298+
PROJECT_MEMBER_ROLE.COPILOT,
299+
],
300+
topcoderRoles: [
301+
USER_ROLE.TOPCODER_ADMIN,
302+
],
296303
scopes: SCOPES_PROJECTS_READ_BILLING_ACCOUNT_DETAILS,
297304
},
298305

src/routes/billingAccounts/get.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ module.exports = [
4545
const sql = `SELECT TopCoder_Billing_Account_Id__c, Mark_Up__c, Active__c from Topcoder_Billing_Account__c tba where TopCoder_Billing_Account_Id__c='${billingAccountId}'`;
4646
req.log.debug(sql);
4747
const billingAccount = await SalesforceService.queryBillingAccount(sql, accessToken, instanceUrl, req.log);
48+
const isMachineToken = _.get(req, 'authUser.isMachine', false);
49+
if (!isMachineToken) {
50+
// delete sensitive information for non machine access
51+
// does not revalidate the scope as it assumes that is already taken care
52+
delete billingAccount.markup;
53+
}
4854
res.json(billingAccount);
4955
} catch (error) {
5056
req.log.error(error);

0 commit comments

Comments
 (0)