diff --git a/controllers/jiraAPIController.js b/controllers/jiraAPIController.js index 1f42ae8..a33bd3a 100644 --- a/controllers/jiraAPIController.js +++ b/controllers/jiraAPIController.js @@ -1,4 +1,4 @@ -const fetch = require('node-fetch'); +const fetch = require('@adobe/node-fetch-retry'); const https = require('https'); function getDefaultHeaders(req) { diff --git a/controllers/jiraController.js b/controllers/jiraController.js index 378aed3..62da707 100644 --- a/controllers/jiraController.js +++ b/controllers/jiraController.js @@ -29,6 +29,9 @@ exports.getUsersWorkLogsAsEvent = function(req, start, end) { if (process.env.JIRA_BASIC_AUTH_USERNAME) { condition = condition && worklog.author.emailAddress == process.env.JIRA_BASIC_AUTH_USERNAME; } + if (process.env.JIRA_AUTH_TYPE =="OAUTH") { + condition = condition && worklog.author.emailAddress == req.user.email; + } return condition; }) .map(worklog => { diff --git a/package-lock.json b/package-lock.json index a3f1f77..420d298 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "plywood", "version": "0.0.3", "dependencies": { + "@adobe/node-fetch-retry": "^2.2.0", "cookie-parser": "~1.4.4", "dayjs": "^1.11.10", "debug": "~2.6.9", @@ -26,6 +27,15 @@ "serve-favicon": "^2.5.0" } }, + "node_modules/@adobe/node-fetch-retry": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@adobe/node-fetch-retry/-/node-fetch-retry-2.2.0.tgz", + "integrity": "sha512-4sNIVGL26G2vzFA+O/CC2Y5dBG6P7QCTuNr/3pRpo1vJUlPt6aiyhlE/wPYR7WF/MSK+y6hkqqjnRMk5/Myfhg==", + "dependencies": { + "abort-controller": "^3.0.0", + "node-fetch": "^2.6.7" + } + }, "node_modules/@fullcalendar/core": { "version": "6.1.9", "license": "MIT", @@ -78,6 +88,17 @@ "version": "1.0.1", "license": "MIT" }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, "node_modules/accepts": { "version": "1.3.8", "license": "MIT", @@ -392,6 +413,14 @@ "node": ">= 0.6" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, "node_modules/express": { "version": "4.18.2", "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", diff --git a/package.json b/package.json index 87c3760..1315c9d 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "start": "node ./bin/www" }, "dependencies": { + "@adobe/node-fetch-retry": "^2.2.0", "cookie-parser": "~1.4.4", "dayjs": "^1.11.10", "debug": "~2.6.9",