Skip to content

Commit

Permalink
Update Formio form submissions endpoints to use the new checkUserData…
Browse files Browse the repository at this point in the history
…() function to return empty arrays instead of 401 Unauthorized responses for helpdesk users with no BAP combo keys
  • Loading branch information
courtneymyers committed Nov 27, 2024
1 parent 06d11fc commit c11d63f
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions app/server/app/utilities/formio.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const {
getBapDataFor2022CRF,
checkFormSubmissionPeriodAndBapStatus,
} = require("../utilities/bap");
const log = require("./logger");
const { checkUserData } = require("../utilities/user");
const log = require("../utilities/logger");

const { NODE_ENV } = process.env;

Expand Down Expand Up @@ -1092,7 +1093,13 @@ function fetchFRFSubmissions({ rebateYear, req, res }) {
const { bapComboKeys } = req;
const { mail } = req.user;

if (bapComboKeys.length === 0) {
const { adminOrHelpdeskUser, noBapComboKeys } = checkUserData({ req });

if (noBapComboKeys) {
if (adminOrHelpdeskUser) {
return res.json([]);
}

const logMessage =
`User with email '${mail}' attempted to fetch ${rebateYear} FRF ` +
`submissions from Formio without any SAM.gov combo keys.`;
Expand Down Expand Up @@ -1345,7 +1352,13 @@ function fetchPRFSubmissions({ rebateYear, req, res }) {
const { bapComboKeys } = req;
const { mail } = req.user;

if (bapComboKeys.length === 0) {
const { adminOrHelpdeskUser, noBapComboKeys } = checkUserData({ req });

if (noBapComboKeys) {
if (adminOrHelpdeskUser) {
return res.json([]);
}

const logMessage =
`User with email '${mail}' attempted to fetch ${rebateYear} PRF ` +
`submissions from Formio without any SAM.gov combo keys.`;
Expand Down Expand Up @@ -1718,7 +1731,13 @@ function fetchCRFSubmissions({ rebateYear, req, res }) {
const { bapComboKeys } = req;
const { mail } = req.user;

if (bapComboKeys.length === 0) {
const { adminOrHelpdeskUser, noBapComboKeys } = checkUserData({ req });

if (noBapComboKeys) {
if (adminOrHelpdeskUser) {
return res.json([]);
}

const logMessage =
`User with email '${mail}' attempted to fetch ${rebateYear} CRF ` +
`submissions from Formio without any SAM.gov combo keys.`;
Expand Down Expand Up @@ -2002,7 +2021,13 @@ function fetchChangeRequests({ rebateYear, req, res }) {
const { bapComboKeys } = req;
const { mail } = req.user;

if (bapComboKeys.length === 0) {
const { adminOrHelpdeskUser, noBapComboKeys } = checkUserData({ req });

if (noBapComboKeys) {
if (adminOrHelpdeskUser) {
return res.json([]);
}

const logMessage =
`User with email '${mail}' attempted to fetch ${rebateYear} Change ` +
`Request form submissions from Formio without any SAM.gov combo keys.`;
Expand Down

0 comments on commit c11d63f

Please sign in to comment.