From 32b3ce205a9687bd6f67fe87be5c008245fbe7cf Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Mon, 3 Feb 2025 13:36:09 +0200 Subject: [PATCH 1/3] fix: add credentials: 'omit' to all calls to recruit --- .circleci/config.yml | 1 + src/server/services/recruitCRM.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f77a5da7..ed1d28cba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -358,6 +358,7 @@ workflows: branches: only: - develop + - fix-gig-apply-issue # This is alternate dev env for parallel testing # Deprecate this workflow due to beta env shutdown # https://topcoder.atlassian.net/browse/CORE-251 diff --git a/src/server/services/recruitCRM.js b/src/server/services/recruitCRM.js index c2d24bc46..ae627c377 100644 --- a/src/server/services/recruitCRM.js +++ b/src/server/services/recruitCRM.js @@ -155,6 +155,7 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, + credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec @@ -198,6 +199,7 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, + credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec @@ -243,6 +245,7 @@ export default class RecruitCRMService { 'Content-Type': 'application/json', Authorization: this.private.authorization, }, + credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec @@ -267,6 +270,7 @@ export default class RecruitCRMService { 'Content-Type': 'application/json', Authorization: this.private.authorization, }, + credentials: 'omit', })), ) .then(async (allPages) => { @@ -311,6 +315,7 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, + credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec @@ -336,6 +341,7 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, + credentials: 'omit', })), ) .then(async (allPages) => { @@ -382,6 +388,7 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, + credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec @@ -430,6 +437,7 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, + credentials: 'omit', }); if (candidateResponse.status >= 300) { const error = { @@ -480,6 +488,7 @@ export default class RecruitCRMService { 'Content-Type': 'application/json', Authorization: this.private.authorization, }, + credentials: 'omit', body: JSON.stringify(form), }); if (workCandidateResponse.status >= 300) { @@ -503,6 +512,7 @@ export default class RecruitCRMService { Authorization: this.private.authorization, ...formHeaders, }, + credentials: 'omit', body: fileData, }); if (fileCandidateResponse.status >= 300) { @@ -528,6 +538,7 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, + credentials: 'omit', }); if (applyResponse.status >= 300) { const errObj = await applyResponse.json(); @@ -554,6 +565,7 @@ export default class RecruitCRMService { 'Content-Type': 'application/json', Authorization: this.private.authorization, }, + credentials: 'omit', body: JSON.stringify({ candidate_slug: candidateData.slug, job_slug: id, @@ -682,6 +694,7 @@ export default class RecruitCRMService { 'Content-Type': 'application/json', Authorization: this.private.authorization, }, + credentials: 'omit', body: JSON.stringify(form), }); if (response.status >= 300) { @@ -704,6 +717,7 @@ export default class RecruitCRMService { Authorization: this.private.authorization, ...formHeaders, }, + credentials: 'omit', body: fileData, }); if (fileResponse.status >= 300) { @@ -740,6 +754,7 @@ export default class RecruitCRMService { headers: { Authorization: this.private.authorization, }, + credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec From 9bf44dc59587e7cbd6f29a070d789f112b41ffe7 Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Mon, 3 Feb 2025 14:19:36 +0200 Subject: [PATCH 2/3] Revert "fix: add credentials: 'omit' to all calls to recruit" This reverts commit 32b3ce205a9687bd6f67fe87be5c008245fbe7cf. --- .circleci/config.yml | 1 - src/server/services/recruitCRM.js | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ed1d28cba..0f77a5da7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -358,7 +358,6 @@ workflows: branches: only: - develop - - fix-gig-apply-issue # This is alternate dev env for parallel testing # Deprecate this workflow due to beta env shutdown # https://topcoder.atlassian.net/browse/CORE-251 diff --git a/src/server/services/recruitCRM.js b/src/server/services/recruitCRM.js index ae627c377..c2d24bc46 100644 --- a/src/server/services/recruitCRM.js +++ b/src/server/services/recruitCRM.js @@ -155,7 +155,6 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, - credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec @@ -199,7 +198,6 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, - credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec @@ -245,7 +243,6 @@ export default class RecruitCRMService { 'Content-Type': 'application/json', Authorization: this.private.authorization, }, - credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec @@ -270,7 +267,6 @@ export default class RecruitCRMService { 'Content-Type': 'application/json', Authorization: this.private.authorization, }, - credentials: 'omit', })), ) .then(async (allPages) => { @@ -315,7 +311,6 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, - credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec @@ -341,7 +336,6 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, - credentials: 'omit', })), ) .then(async (allPages) => { @@ -388,7 +382,6 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, - credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec @@ -437,7 +430,6 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, - credentials: 'omit', }); if (candidateResponse.status >= 300) { const error = { @@ -488,7 +480,6 @@ export default class RecruitCRMService { 'Content-Type': 'application/json', Authorization: this.private.authorization, }, - credentials: 'omit', body: JSON.stringify(form), }); if (workCandidateResponse.status >= 300) { @@ -512,7 +503,6 @@ export default class RecruitCRMService { Authorization: this.private.authorization, ...formHeaders, }, - credentials: 'omit', body: fileData, }); if (fileCandidateResponse.status >= 300) { @@ -538,7 +528,6 @@ export default class RecruitCRMService { 'Content-Type': req.headers['content-type'], Authorization: this.private.authorization, }, - credentials: 'omit', }); if (applyResponse.status >= 300) { const errObj = await applyResponse.json(); @@ -565,7 +554,6 @@ export default class RecruitCRMService { 'Content-Type': 'application/json', Authorization: this.private.authorization, }, - credentials: 'omit', body: JSON.stringify({ candidate_slug: candidateData.slug, job_slug: id, @@ -694,7 +682,6 @@ export default class RecruitCRMService { 'Content-Type': 'application/json', Authorization: this.private.authorization, }, - credentials: 'omit', body: JSON.stringify(form), }); if (response.status >= 300) { @@ -717,7 +704,6 @@ export default class RecruitCRMService { Authorization: this.private.authorization, ...formHeaders, }, - credentials: 'omit', body: fileData, }); if (fileResponse.status >= 300) { @@ -754,7 +740,6 @@ export default class RecruitCRMService { headers: { Authorization: this.private.authorization, }, - credentials: 'omit', }); if (response.status === 429) { await new Promise(resolve => setTimeout(resolve, 30000)); // wait 30sec From 5b338a07f21f642fc39344dd4fd21d899f06d9be Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Mon, 3 Feb 2025 14:28:02 +0200 Subject: [PATCH 3/3] fix: add debug logs --- .circleci/config.yml | 1 + src/server/routes/recruitCRM.js | 8 +++++++- src/server/services/recruitCRM.js | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f77a5da7..ed1d28cba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -358,6 +358,7 @@ workflows: branches: only: - develop + - fix-gig-apply-issue # This is alternate dev env for parallel testing # Deprecate this workflow due to beta env shutdown # https://topcoder.atlassian.net/browse/CORE-251 diff --git a/src/server/routes/recruitCRM.js b/src/server/routes/recruitCRM.js index d523744a3..9983ded1a 100644 --- a/src/server/routes/recruitCRM.js +++ b/src/server/routes/recruitCRM.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ /** * The routes related to RecruitCRM.io integration */ @@ -50,7 +51,12 @@ const applyOptions = { allowedHeaders: ['Content-Type', 'Authorization'], }; routes.options('/jobs/:id/apply', cors(applyOptions)); -routes.post('/jobs/:id/apply', cors(applyOptions), (req, res, next) => authenticator(authenticatorOptions)(req, res, next), upload.single('resume'), (req, res, next) => new RecruitCRMService().applyForJob(req, res, next)); +routes.post('/jobs/:id/apply', (req, res, next) => { + console.log('debug: /jobs/:id/apply - req.headers', req.headers); + console.log('debug: /jobs/:id/apply - req.body', req.body); + console.log('debug: /jobs/:id/apply - req.params', req.params); + next(); +}, cors(applyOptions), (req, res, next) => authenticator(authenticatorOptions)(req, res, next), upload.single('resume'), (req, res, next) => new RecruitCRMService().applyForJob(req, res, next)); routes.options('/candidates/search', cors()); routes.get('/candidates/search', cors(), (req, res, next) => new RecruitCRMService().searchCandidates(req, res, next)); diff --git a/src/server/services/recruitCRM.js b/src/server/services/recruitCRM.js index c2d24bc46..27274630c 100644 --- a/src/server/services/recruitCRM.js +++ b/src/server/services/recruitCRM.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ /** * Server-side functions necessary for effective integration with recruitCRM */ @@ -413,6 +414,7 @@ export default class RecruitCRMService { async applyForJob(req, res, next) { const { id } = req.params; const { body, file } = req; + console.log('debug: applyForJob', id, body, file); const form = JSON.parse(body.form); const fileData = new FormData(); if (file) { @@ -605,6 +607,7 @@ export default class RecruitCRMService { const data = await applyResponse.json(); return res.send(data); } catch (err) { + console.log('applyForJob error', err); return next(err); } }