Skip to content

Commit

Permalink
Merge pull request #355 from cisagov/add-static-508-banner-text-for-l…
Browse files Browse the repository at this point in the history
…ocal-dev-builds

Add static 508 banner text for local dev builds and cleanup logging
  • Loading branch information
schmelz21 authored Jun 27, 2024
2 parents 856522c + de46d19 commit 0fb5d32
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
10 changes: 0 additions & 10 deletions backend/src/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ app.post('/auth/okta-callback', async (req, res) => {
const clientId = process.env.REACT_APP_COGNITO_CLIENT_ID;
const callbackUrl = process.env.REACT_APP_COGNITO_CALLBACK_URL;
const domain = process.env.REACT_APP_COGNITO_DOMAIN;
console.log('Okta ClientID: ', clientId);
console.log('Okta CallbackURL: ', callbackUrl);
console.log('Okta Domain: ', domain);

if (!code) {
return res.status(400).json({ message: 'Missing authorization code' });
Expand All @@ -202,7 +199,6 @@ app.post('/auth/okta-callback', async (req, res) => {
},
body: tokenData
});
console.log('Okta token response: ', response);
const { id_token, access_token, refresh_token } = await response.json();

if (!id_token) {
Expand All @@ -216,12 +212,6 @@ app.post('/auth/okta-callback', async (req, res) => {

const cognitoUsername = decodedToken['cognito:username'];
const oktaId = decodedToken['custom:OKTA_ID'];
console.log('Cognito Username:', cognitoUsername);
console.log('Cognito OKTA_ID:', oktaId);

console.log('ID Token:', id_token);
console.log('Decoded Token:', decodedToken);

jwt.verify(
id_token,
auth.getOktaKey,
Expand Down
1 change: 0 additions & 1 deletion backend/src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export const callback = async (event, context) => {
user.loginBlockedByMaintenance = loginBlocked;
user.save();
}
console.log(user);

// If user does not exist, create it
if (!user) {
Expand Down
1 change: 0 additions & 1 deletion backend/src/api/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ export const sendRegistrationApprovedEmail = async (
*/
async function isMajorActiveMaintenance(): Promise<boolean> {
const now = new Date();
console.log(now);
try {
// DB connection
await connectToDatabase();
Expand Down
28 changes: 25 additions & 3 deletions backend/src/api/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ import { validateBody, wrapHandler, NotFound, Unauthorized } from './helpers';
import { isGlobalWriteAdmin } from './auth';
import S3Client from '../tasks/s3-client';

// 508 Warning Banner S3 filename
const bannerFileName = '508warningtext.txt';

// Default 508 Warning Banner for local dev
const default508Banner =
'CISA is committed to providing access for all individuals with disabilities, \
including members of the public and all employees. While this website is not \
yet fully accessible to users with disabilities as required by Section \
[508](https://cisa.gov/accessibility) federal law, CISA is working diligently \
to resolve those issues. If you experience accessibility issues, please email \
[[email protected]](mailto:[email protected]) for assistance.';

class NewNotification {
@IsDateString()
startDatetime?: string;
Expand Down Expand Up @@ -99,8 +111,6 @@ export const list = wrapHandler(async (event) => {
}
});

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

return {
statusCode: 200,
body: JSON.stringify(result)
Expand Down Expand Up @@ -161,16 +171,28 @@ export const update = wrapHandler(async (event) => {
* - Notifications
*/
export const get508Banner = wrapHandler(async () => {
const bannerFileName = '508warningtext.txt';
// Return hardcoded banner for local builds
if (process.env.IS_LOCAL) {
console.log('Using default banner for 508 warning: ', default508Banner);
// API Response
return {
statusCode: 200,
body: JSON.stringify(default508Banner)
};
}

// Handle normal S3 logic
try {
const client = new S3Client();
const bannerResult = await client.getEmailAsset(bannerFileName);
// API Response
return {
statusCode: 200,
body: JSON.stringify(bannerResult)
};
} catch (error) {
console.log('S3 Banner Error: ', error);
// API Error Response
return {
statusCode: 500,
body: 'Error retrieving file from S3. See details in logs.'
Expand Down

0 comments on commit 0fb5d32

Please sign in to comment.