Skip to content

Commit f919751

Browse files
authored
Merge pull request #646 from topcoder-platform/dev
feat: use token when calling DC
2 parents cf45aa4 + 6081ffb commit f919751

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/common/m2m-helper.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ class M2MHelper {
66
static m2m = null;
77

88
constructor() {
9-
M2MHelper.m2m = m2mAuth(_.pick(config, ["AUTH0_URL", "AUTH0_AUDIENCE", "TOKEN_CACHE_TIME"]));
9+
M2MHelper.m2m = m2mAuth(
10+
_.pick(config, ["AUTH0_URL", "AUTH0_AUDIENCE", "TOKEN_CACHE_TIME", "AUTH0_PROXY_SERVER_URL"])
11+
);
1012
}
1113
/**
1214
* Get M2M token.

src/services/ChallengeService.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const {
4444
convertToISOString,
4545
} = require("../common/challenge-helper");
4646
const deepEqual = require("deep-equal");
47+
const { getM2MToken } = require("../common/m2m-helper");
4748

4849
const challengeDomain = new ChallengeDomain(GRPC_CHALLENGE_SERVER_HOST, GRPC_CHALLENGE_SERVER_PORT);
4950
const phaseAdvancer = new PhaseAdvancer(challengeDomain);
@@ -1027,6 +1028,7 @@ async function createChallenge(currentUser, challenge, userToken) {
10271028

10281029
grpcMetadata.set("handle", currentUser.handle);
10291030
grpcMetadata.set("userId", currentUser.userId);
1031+
grpcMetadata.set("token", await getM2MToken());
10301032

10311033
convertPrizeSetValuesToCents(challenge.prizeSets);
10321034
const ret = await challengeDomain.create(challenge, grpcMetadata);
@@ -1791,6 +1793,7 @@ async function updateChallenge(currentUser, challengeId, data) {
17911793

17921794
grpcMetadata.set("handle", currentUser.handle);
17931795
grpcMetadata.set("userId", currentUser.userId);
1796+
grpcMetadata.set("token", await getM2MToken());
17941797

17951798
if (updateInput.prizeSetUpdate != null) {
17961799
convertPrizeSetValuesToCents(updateInput.prizeSetUpdate.prizeSets);

0 commit comments

Comments
 (0)