Skip to content

Commit

Permalink
QA fixes for parkGet (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidclaveau authored Jul 31, 2024
1 parent d542477 commit 9c263e7
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 16 deletions.
4 changes: 3 additions & 1 deletion arSam/handlers/activity/GET/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ exports.handler = async (event, context) => {

try {
let permissionObject = event.requestContext.authorizer
permissionObject.roles = JSON.parse(permissionObject.roles)
permissionObject.roles = JSON.parse(permissionObject?.roles);
permissionObject.isAdmin = JSON.parse(permissionObject?.isAdmin || false);
permissionObject.isAuthenticated = JSON.parse(permissionObject?.isAuthenticated || false)

if (!permissionObject.isAuthenticated) {
logger.info("**NOT AUTHENTICATED, PUBLIC**");
Expand Down
4 changes: 3 additions & 1 deletion arSam/handlers/activity/POST/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ async function main(event, context, lock = null) {

const warnIfVariance = event.queryStringParameters?.hasOwnProperty('warn') || false;
let permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject.roles);
permissionObject.roles = JSON.parse(permissionObject?.roles);
permissionObject.isAdmin = JSON.parse(permissionObject?.isAdmin || false);
permissionObject.isAuthenticated = JSON.parse(permissionObject?.isAuthenticated || false);

if (!permissionObject.isAuthenticated) {
logger.info("**NOT AUTHENTICATED, PUBLIC**");
Expand Down
4 changes: 3 additions & 1 deletion arSam/handlers/export-variance/GET/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ exports.handler = async (event, context) => {

try {
let permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject.roles);
permissionObject.roles = JSON.parse(permissionObject?.roles);
permissionObject.isAdmin = JSON.parse(permissionObject?.isAdmin || false);
permissionObject.isAuthenticated = JSON.parse(permissionObject?.isAuthenticated || false);

if (!permissionObject.isAuthenticated) {
return sendResponse(403, { msg: "Error: Not authenticated" }, context);
Expand Down
4 changes: 3 additions & 1 deletion arSam/handlers/export/GET/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ exports.handler = async (event, context) => {

try {
let permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject.roles);
permissionObject.roles = JSON.parse(permissionObject?.roles);
permissionObject.isAdmin = JSON.parse(permissionObject?.isAdmin || false);
permissionObject.isAuthenticated = JSON.parse(permissionObject?.isAuthenticated || false);

if (!permissionObject.isAuthenticated) {
return sendResponse(403, { msg: "Error: UnAuthenticated." }, context);
Expand Down
6 changes: 4 additions & 2 deletions arSam/handlers/fiscalYearEnd/POST/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ async function handleLockUnlock(isLocked, event, context) {

async function checkPermissions(event) {

const permissionObject = event.requestContext.authorizer
permissionObject.roles = JSON.parse(permissionObject.roles)
let permissionObject = event.requestContext.authorizer
permissionObject.roles = JSON.parse(permissionObject?.roles);
permissionObject.isAdmin = JSON.parse(permissionObject?.isAdmin || false);
permissionObject.isAuthenticated = JSON.parse(permissionObject?.isAuthenticated || false)

if (!permissionObject.isAdmin) {
throw {
Expand Down
6 changes: 4 additions & 2 deletions arSam/handlers/park/GET/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ exports.handler = async (event, context) => {
};

try {
const permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject.roles);
let permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject?.roles);
permissionObject.isAdmin = JSON.parse(permissionObject?.isAdmin || false);
permissionObject.isAuthenticated = JSON.parse(permissionObject?.isAuthenticated || false);

if (!permissionObject.isAuthenticated) {
logger.info("**NOT AUTHENTICATED, PUBLIC**");
Expand Down
6 changes: 4 additions & 2 deletions arSam/handlers/park/POST/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ const { dynamoClient,
exports.handler = async (event, context) => {
logger.debug("Park POST:", event);
try {
const permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject.roles);
let permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject?.roles);
permissionObject.isAdmin = JSON.parse(permissionObject?.isAdmin || false);
permissionObject.isAuthenticated = JSON.parse(permissionObject?.isAuthenticated || false);

if (!permissionObject.isAuthenticated) {
logger.info("**NOT AUTHENTICATED, PUBLIC**");
Expand Down
6 changes: 4 additions & 2 deletions arSam/handlers/subArea/POST/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ const SSO_CLIENT_ID = process.env.SSO_CLIENT_ID || 'default-client';
exports.handler = async (event, context) => {
logger.debug('Subarea POST:', event);
try {
const permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject.roles);
let permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject?.roles);
permissionObject.isAdmin = JSON.parse(permissionObject?.isAdmin || false);
permissionObject.isAuthenticated = JSON.parse(permissionObject?.isAuthenticated || false);

if (!permissionObject.isAuthenticated) {
logger.info('**NOT AUTHENTICATED, PUBLIC**');
Expand Down
6 changes: 4 additions & 2 deletions arSam/handlers/variance/GET/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ exports.handler = async (event, context) => {
}

try {
const permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject.roles);
let permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject?.roles);
permissionObject.isAdmin = JSON.parse(permissionObject?.isAdmin || false);
permissionObject.isAuthenticated = JSON.parse(permissionObject?.isAuthenticated || false);

// Only admins see this route.
if (permissionObject.isAdmin) {
Expand Down
6 changes: 4 additions & 2 deletions arSam/handlers/variance/PUT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ exports.handler = async (event, context) => {
logger.debug("Variance PUT:", event);

try {
const permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject.roles);
let permissionObject = event.requestContext.authorizer;
permissionObject.roles = JSON.parse(permissionObject?.roles);
permissionObject.isAdmin = JSON.parse(permissionObject?.isAdmin || false);
permissionObject.isAuthenticated = JSON.parse(permissionObject?.isAuthenticated || false);

if (!permissionObject.isAuthenticated) {
logger.info("**NOT AUTHENTICATED, PUBLIC**");
Expand Down

0 comments on commit 9c263e7

Please sign in to comment.