Skip to content

Commit

Permalink
Merge pull request #2584 from cisagov/2576-fix-organizationlist-compo…
Browse files Browse the repository at this point in the history
…nent

Revert Access-Control-Allow-Origin settings; Add logging to list /organizations.
  • Loading branch information
cduhn17 authored Feb 28, 2024
2 parents e29a8a5 + f7af611 commit 2975c53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
10 changes: 1 addition & 9 deletions backend/src/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@ app.use(express.json({ strict: false }));

app.use(
cors({
origin: [
'api.staging-cd.crossfeed.cyber.dhs.gov',
'api.crossfeed.cyber.dhs.gov',
'api.staging.crossfeed.cyber.dhs.gov',
'crossfeed.cyber.dhs.gov',
'staging.crossfeed.cyber.dhs.gov',
'staging-cd.crossfeed.cyber.dhs.gov',
/localhost$/
],
origin: [/.*crossfeed\.cyber\.dhs\.gov$/, /localhost$/],
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']
})
);
Expand Down
6 changes: 6 additions & 0 deletions backend/src/api/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ export const create = wrapHandler(async (event) => {
* - Organizations
*/
export const list = wrapHandler(async (event) => {
console.log('list function called with event: ', event);

if (!isGlobalViewAdmin(event) && getOrgMemberships(event).length === 0) {
return {
//TODO: Should we return a 403?
Expand All @@ -375,6 +377,8 @@ export const list = wrapHandler(async (event) => {
};
}
await connectToDatabase();
console.log('Database connected');

let where: any = { parent: null };
if (!isGlobalViewAdmin(event)) {
where = { id: In(getOrgMemberships(event)), parent: null };
Expand All @@ -385,6 +389,8 @@ export const list = wrapHandler(async (event) => {
order: { name: 'ASC' }
});

console.log('Organization.find result: ', result);

return {
statusCode: 200,
body: JSON.stringify(result)
Expand Down
10 changes: 1 addition & 9 deletions frontend/scripts/constants.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//CORS Options
export const ALLOW_ORIGIN = [
'api.staging-cd.crossfeed.cyber.dhs.gov',
'api.crossfeed.cyber.dhs.gov',
'api.staging.crossfeed.cyber.dhs.gov',
'crossfeed.cyber.dhs.gov',
'staging.crossfeed.cyber.dhs.gov',
'staging-cd.crossfeed.cyber.dhs.gov',
/localhost$/
];
export const ALLOW_ORIGIN = [/.*crossfeed\.cyber\.dhs\.gov$/, /localhost$/];
export const ALLOW_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'];

0 comments on commit 2975c53

Please sign in to comment.